|
@@ -4,6 +4,7 @@ import com.aliyun.odps.udf.UDF;
|
|
import com.aliyun.odps.utils.StringUtils;
|
|
import com.aliyun.odps.utils.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -13,7 +14,7 @@ import java.util.regex.Pattern;
|
|
*/
|
|
*/
|
|
public class replace_split extends UDF {
|
|
public class replace_split extends UDF {
|
|
|
|
|
|
- public String evaluate(String name, String historyName,String split) {
|
|
|
|
|
|
+ public String evaluate(String name, String historyName, String split) {
|
|
ArrayList<String> list = new ArrayList<>();
|
|
ArrayList<String> list = new ArrayList<>();
|
|
if (StringUtils.isBlank(name) && StringUtils.isBlank(historyName)) {
|
|
if (StringUtils.isBlank(name) && StringUtils.isBlank(historyName)) {
|
|
return "";
|
|
return "";
|
|
@@ -35,10 +36,22 @@ public class replace_split extends UDF {
|
|
return String.join(split, list);
|
|
return String.join(split, list);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static final Pattern p = Pattern.compile("^(?<name>.*?)(?<cardNum>[0-9xX*]*?)$");
|
|
|
|
+
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
|
+ String str = "徐州圣1426231973****081X";
|
|
|
|
+ Matcher matcher = p.matcher(str);
|
|
|
|
+ String cardNum = "";
|
|
String name = "";
|
|
String name = "";
|
|
- String historyName = "中国邮政集团公司山南地区分公司\t;\t西藏自治区邮政公司山南地区分公司\t;\t中国邮政集团公司山南市分公司\t;";
|
|
|
|
- System.out.println(new replace_split().evaluate(name,historyName,"@@"));
|
|
|
|
|
|
+ if (matcher.matches()) {
|
|
|
|
+ cardNum = matcher.group("cardNum");
|
|
|
|
+ name = matcher.group("name");
|
|
|
|
+ } else {
|
|
|
|
+ name = str;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println("name: " + name);
|
|
|
|
+ System.out.println("cardNum: " + cardNum);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|