On the basic syntax of regular expressions and its application in Java __java

Source: Internet
Author: User

First, ^$ indicates the start and end position, if you need to extract the text do not add this character, unless you understand what they mean.

Second, "." Represents all characters except line breaks, but [. \ n] cannot match all characters, and can be used in practical applications such as: [\s\s\] [\w\w] .... Wait, whatever.

Third, match two brackets: \ ([\\s\\s]+ ([^ ()]*\\)) +[\\s\\s]*\\, the depth of the assembly is written very complex

How regular expressions are used in Java:

Pattern PA2 = Pattern.compile (p2);

Matcher m2 = pa2.matcher (t);

M2.find ();//must first find () before calling group, or it will not be found, there is a M2.match () method, if the full text match will return true, and the Find () method returns true as long as there is a match
M2.group ();



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.