Accumulated Regular Expressions every day (4)

Source: Internet
Author: User
// P ("hello sir ". matches ("^ h. * "); // true indicates the beginning of the ^ line. * Represents zero or multiple occurrences of any character P ("hello sir ". matches ("^. * "); // false P (" H ". matches ("^ h. * "); // true P (" hello sir ". matches (". * IR $ "); // The End of the true $ row. This sentence is the string P (" hello sir ") ending with IR ". matches (". * I $ "); // false P (" hello sir ". matches (". * r$ "); // true P (" hello sir ". matches ("^ h [A-Z] {1, 3} O \ B. * "); // true \ B indicates the word boundary, such as space, and a blank line break p (" hello sir ". matches ("^ h [A-Z] {1, 3} o. * "); // true P (" hellosir ". matches ("^ h [A-Z] {1, 3} O \ B. * "); // false P (" Hello \ nsir ". matches ("^ h [A-Z] {1, 3} O \ B. * "); // true P (" Hello \ nsir ". matches ("^ h [A-Z] {1, 3} O \ B. * "); // false note \ n only one diagonal line is incorrectly matched // blank line P (" \ n ". matches ("^ [\ s & [^ \ n] * \ N $"); // true indicates that the start is a blank character, but not a line break, appears zero or multiple times, ending with the line break p ("AAA 8888c ". matches (". * \ D {4 }. "); // true P (" aaa8888c ". matches ("^ .. \ D {4 }. "); // true P (" AAA 8888c ". matches ("^ .. \ D {4 }. "); // false, note that there are still white spaces, so the two points do not work P (" AAA 8888c ". matches ("^... \ D {4 }. "); // true P (" AAA 8888c ". matches (". * \ B \ D {4 }. "); // true here it matches \ B with a blank space character P (" aaa8888c ". matches (". * \ D {4 }. "); // true P (" aaa8888c ". matches (". * \ B \ D {4 }. "); // false the error P (" AAA 8888c ". matches ("^... \ D {4} C $ "); // true P (" AAA 8888c ". matches ("A {3 }. \ D {4} C $ "); // true P (" AAA 8888c ". matches ("A {3} \ D {4} C $"); // true // note the following two. The second one is missing a space, so it is wrong. Pay attention to P ("AAA 8888c ". matches ("A {3} \ B \ D {4} C $"); // true P ("AAA 8888c ". matches ("A {3} \ B \ D {4} C $"); // false because a space is missing after {3}
public static void p(Object o) {        System.out.println(o);    }

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.