Java matches Regular Expressions in Chinese and java matches regular expressions.

Source: Internet
Author: User

Java matches Regular Expressions in Chinese and java matches regular expressions.

 

[\u4E00-\u9FA5]*

 

Public static void regxChinese () {// String source = "<span title = '5 star hotels 'class = 'dx dx5'> "; // convert the string to be matched to lower case // source = source. toLowerCase (); // The regular expression String reg_charset = "<span [^>] *? Title = \ '([0-9] * [\ s | \ S] * [\ u4E00-\ u9FA5] *) \ '[\ s | \ S] * class = \' [a-z] * [\ s | \ S] * [a-z] * [0 -9] * \ '"; pattern p = Pattern. compile (reg_charset); Matcher m = p. matcher (source); while (m. find () {System. out. println (m. group (1) ;}} public static void regxChinese () {// String source = "<span title = '5-star hotels 'class = 'dx dx5'> "; // convert the string to be matched to lower case // source = source. toLowerCase (); // Regular Expression of the matched String r Eg_charset = "<span [^>] *? Title = \ '([0-9] * [\ s | \ S] * [\ u4E00-\ u9FA5] *) \ '[\ s | \ S] * class = \' [a-z] * [\ s | \ S] * [a-z] * [0 -9] * \ '"; pattern p = Pattern. compile (reg_charset); Matcher m = p. matcher (source); while (m. find () {System. out. println (m. group (1 ));}}

Java regular expressions match real names (27 Chinese or 310 English)

Public static void main (String [] args ){
String regx = "([\ u4E00-\ u9FA5] {}) | ([a-zA-Z }))";
System. out. println (Pattern. matches (regx, "I am, I am, I am "));
System. out. println (Pattern. matches (regx, "aBcDefghij "));

}

In java, how does one use regular expressions to match strings with fixed byte lengths that can contain Chinese characters?

I can only help you to write a string that determines whether it is composed of numbers and English characters.
^ (? = [A-Za-z0-9] *) (? = [U4e00-u9fa5]) [\ u4e00-\ u9fa5A-Za-z0-9] * $

Is there 10 (two dubyte counts)? Can you use java to write code?
 

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.