Commit 7ca35260 by java-李谡

修改号码格式化

parent 0d005762
...@@ -250,13 +250,13 @@ public class Util { ...@@ -250,13 +250,13 @@ public class Util {
if(mobile == null || mobile.length() == 0) if(mobile == null || mobile.length() == 0)
return mobile; return mobile;
try { try {
String[] species = mobile.split("\\s+");// 只使用第一个手机号 // String[] species = mobile.split("\\s+");// 只使用第一个手机号
if(species.length>1 && species[0].matches("1\\d+") && species[1].matches("1\\d+")){ // if(species.length>1 && species[0].matches("1\\d+") && species[1].matches("1\\d+")){
//
mobile = species[0]; // mobile = species[0];
} // }
mobile = mobile.replaceAll("+", "+");// 处理错误字符 mobile = mobile.replaceAll("+", "+");// 处理错误字符
mobile = mobile.replaceAll("[^0-9|+]+", "");// 将非电话号码替换为空 mobile = mobile.replaceAll("[^0-9^,^#|+]+", "");// 将非电话号码替换为空
// System.out.println("mobile:"+mobile); // System.out.println("mobile:"+mobile);
if(mobile.startsWith("+")){// 国外手机号,前面加拨3个0 if(mobile.startsWith("+")){// 国外手机号,前面加拨3个0
...@@ -297,7 +297,7 @@ public class Util { ...@@ -297,7 +297,7 @@ public class Util {
if(workPhone == null || workPhone.length() == 0) if(workPhone == null || workPhone.length() == 0)
return workPhone; return workPhone;
try { try {
workPhone = workPhone.replaceAll("[^\\d|+]+", ""); workPhone = workPhone.replaceAll("[^\\d^,^#|+]+", "");
if(workPhone.matches("0+")){ // 非座机号设置为空 if(workPhone.matches("0+")){ // 非座机号设置为空
workPhone = ""; workPhone = "";
} else if(workPhone.startsWith("0") == false){ // 非0开头的号码需要处理 } else if(workPhone.startsWith("0") == false){ // 非0开头的号码需要处理
...@@ -766,6 +766,8 @@ public class Util { ...@@ -766,6 +766,8 @@ public class Util {
//// System.out.println(Util.getRelativePath("https://ifos.jdair.net/foc/static/2017/01/13/actuals/images/user/jpg/23198d70826ac171ee03ed5cd3d14c27.jpg")); //// System.out.println(Util.getRelativePath("https://ifos.jdair.net/foc/static/2017/01/13/actuals/images/user/jpg/23198d70826ac171ee03ed5cd3d14c27.jpg"));
// } // }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(Util.entryptPassword("123456"));
System.out.println(Util.formatedWorkPhone("00016462485041,9694264088,053601046310#"));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment