You need to sign in to do that
Don't have an account?
Regular Expression to find Chinese characters
Hi Folks,
If a string contains atleast one chinese character then i have return a boolean. I am looking for exact regular expression to use in pattern.matches method.
Any help much appreciated.
If a string contains atleast one chinese character then i have return a boolean. I am looking for exact regular expression to use in pattern.matches method.
Any help much appreciated.
Below code will help you.
public static Boolean containsChineseCharacters(String InputString)
{
Pattern p = Pattern.compile('\\p{IsHan}');
Matcher m = p.matcher( InputString );
return m.find();
}
Please let us know if this helps you.
Thanks and Regards
sandhya reddy
Thanks for sharing. This pattern '\\p{IsHan' detects Japanese character as well. Is there way to check only Chinese characters. ?
https://www.regular-expressions.info/unicode.html
Regards