mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修改汉字正则覆盖更多汉字范围
This commit is contained in:
parent
c075b30858
commit
31333e476d
@ -21,8 +21,9 @@ public interface RegexPool {
|
|||||||
String WORD = "[a-zA-Z]+";
|
String WORD = "[a-zA-Z]+";
|
||||||
/**
|
/**
|
||||||
* 单个中文汉字
|
* 单个中文汉字
|
||||||
|
* <br/>参照维基百科汉字Unicode范围(https://zh.wikipedia.org/wiki/%E6%B1%89%E5%AD%97 页面右侧)
|
||||||
*/
|
*/
|
||||||
String CHINESE = "[\u4E00-\u9FFF]";
|
String CHINESE = "[\u2E80-\u2EFF\u2F00-\u2FDF\u31C0-\u31EF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uD840\uDC00-\uD869\uDEDF\uD869\uDF00-\uD86D\uDF3F\uD86D\uDF40-\uD86E\uDC1F\uD86E\uDC20-\uD873\uDEAF\uD87E\uDC00-\uD87E\uDE1F]";
|
||||||
/**
|
/**
|
||||||
* 中文汉字
|
* 中文汉字
|
||||||
*/
|
*/
|
||||||
|
@ -162,9 +162,18 @@ public class ValidatorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void isChineseTest(){
|
public void isChineseTest(){
|
||||||
Assert.assertTrue(Validator.isChinese("全都是中文"));
|
Assert.assertTrue(Validator.isChinese("全都是中文"));
|
||||||
|
Assert.assertTrue(Validator.isChinese("㐓㐘"));
|
||||||
Assert.assertFalse(Validator.isChinese("not全都是中文"));
|
Assert.assertFalse(Validator.isChinese("not全都是中文"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hasChineseTest() {
|
||||||
|
Assert.assertTrue(Validator.hasChinese("黄单桑米"));
|
||||||
|
Assert.assertTrue(Validator.hasChinese("Kn 四兄弟"));
|
||||||
|
Assert.assertTrue(Validator.hasChinese("\uD840\uDDA3"));
|
||||||
|
Assert.assertFalse(Validator.hasChinese("Abc"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isUUIDTest(){
|
public void isUUIDTest(){
|
||||||
Assert.assertTrue(Validator.isUUID(IdUtil.randomUUID()));
|
Assert.assertTrue(Validator.isUUID(IdUtil.randomUUID()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user