|
@@ -0,0 +1,45 @@
|
|
|
+package com.winhc.bigdata.udf;
|
|
|
+
|
|
|
+import com.aliyun.odps.udf.UDF;
|
|
|
+import com.aliyun.odps.utils.StringUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: π
|
|
|
+ * @Date: 2020/5/14 16:26
|
|
|
+ * @Description: 字符串去符号
|
|
|
+ */
|
|
|
+public class replace_split extends UDF {
|
|
|
+
|
|
|
+ public String evaluate(String name, String historyName,String split) {
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
+ if (StringUtils.isBlank(name) && StringUtils.isBlank(historyName)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(name)) {
|
|
|
+ list.add(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(historyName)) {
|
|
|
+ String[] arrs = historyName.split("\\t;\\t");
|
|
|
+ for (String n : arrs) {
|
|
|
+ if (StringUtils.isNotBlank(n)) {
|
|
|
+ String s1 = n.replaceAll("\\t;", "");
|
|
|
+ list.add(s1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return String.join(split, list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String name = "";
|
|
|
+ String historyName = "中国邮政集团公司山南地区分公司\t;\t西藏自治区邮政公司山南地区分公司\t;\t中国邮政集团公司山南市分公司\t;";
|
|
|
+ System.out.println(new replace_split().evaluate(name,historyName,"@@"));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|