public class Patternth {
public static void Main (string[] args) {
String paramvalue= "Hello, 1233333, not good";
System.out.println (Patternth.getchinese (paramvalue));
}
/*1, at least matching the wording of a Chinese character.
2, these two Unicode values are exactly the head and tail of the Chinese characters in the Unicode table.
3, "[]" represents the value inside the one can be, the "+" at the back of the representation at least 1 times, together that is at least match a Chinese character.
*/
public static string Getchinese (string paramvalue) {
String regex = "([\u4e00-\u9fa5]+)";
String str = "";
Matcher Matcher = Pattern.compile (regex). Matcher (Paramvalue);
while (Matcher.find ()) {
str+= matcher.group (0);
}
return str;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service