2 changed files with 92 additions and 51 deletions
@ -0,0 +1,27 @@ |
|||
package com.bnyer.common.core.utils; |
|||
|
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
/** |
|||
* 汉译英工具类 |
|||
*/ |
|||
public class TranslateUtils { |
|||
|
|||
/** |
|||
* 字符串是否包含中文 |
|||
* |
|||
* @param str 待校验字符串 |
|||
* @return true 包含中文字符 false 不包含中文字符 |
|||
* @throws Exception |
|||
*/ |
|||
public static boolean isContainChinese(String str) throws Exception { |
|||
|
|||
if (StringUtils.isEmpty(str)) { |
|||
throw new Exception("文本内容为空!"); |
|||
} |
|||
Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]"); |
|||
Matcher m = p.matcher(str); |
|||
return m.find(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue