Commit 603a8df8 authored by 技术部-任文超's avatar 技术部-任文超

监控字符集未匹配的特殊汉字,打印监控信息

parent d10a846c
......@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.util;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.util.encrypt.MD5Util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.util.Calendar;
......@@ -13,10 +14,11 @@ import java.util.regex.Pattern;
* Created by Miraculous on 15/7/6.
* 所有validate为真返回true, 否则返回false
*/
@Slf4j
public class ValidationUtil {
private static String phoneRegExp = "^1[3456789][0-9]{9}$";
private static String chineseNameRegExp = "^[\u4e00-\u9fa5]+(\\.|·)?[\u4e00-\u9fa5]+$";
private static String chineseNameRegExp = "^[\u4e00-\u9fff]+(\\.|·)?[\u4e00-\u9fff]+$";
private static String ipv4RegExp = "^((2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)\\.){3}(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)$";
private static String localIpv4RegExp = "^((172\\.(1[0-6]|2[0-9]|3[01]))|(192\\.168|169\\.254)|((127|10)\\.(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)))(\\.(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)){2}$";
......@@ -39,7 +41,15 @@ public class ValidationUtil {
return false;
}
Matcher matcher = chinesePattern.matcher(chinese);
return matcher.find();
boolean valid = matcher.find();
if(!valid){
StringBuilder uniCodeTemp = new StringBuilder();
for(int i=0;i<chinese.length();i++){
uniCodeTemp.append("\\u").append(Integer.toHexString((int)chinese.charAt(i)));
}
log.info("[ValidationUtil][validateChinese]:[chinese][unicode][length]:[{}][{}][{}]", chinese, chinese.length(), uniCodeTemp);
}
return valid;
}
/**
......
package common;
import cn.quantgroup.xyqb.util.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Slf4j
@RunWith(JUnit4.class)
public class TestValidationUtil {
public static void main(String[] args){
String[][] contacts = {
{"18589336973","刘䶮"},
{"13198898119","张鑫鑫"},
{"16620800072","许慧梓"},
{"1508964071 ","1508964071 "},
{"16603429800","张泽浩"},
{"17393151197","李小林?"},
{"18721920553","王正\u202D"}};
for(String[] ctc : contacts) {
log.info("phoneNo:[{}][{}],name:[{}][{}],name-trim:[{}][{}]",
ctc[0],ValidationUtil.validatePhoneNo(ctc[0]),
ctc[1], ValidationUtil.validateChinese(ctc[1]),
ctc[1].trim(),ValidationUtil.validateChinese(ctc[1].trim()));
}
}
@Test
public void testString() {
}
}
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