Java Learning Note-4 regular expressions

Source: Internet
Author: User

1 、-? \\d+ One or no minus, followed by several numbers;

2, (-|\\+)? \\d+ a minus sign or a plus sign or none, followed by a number of numbers;

3, \\w+ One or more non-word characters;

4, \\w+ one or more word characters;

5, (ABC) + one or more ABC;

6, abc+ AB followed by one or more C;

7, (ABC) {2,} ABC appears at least 2 times consecutively;

8, (ABC) {2} ABC appeared exactly 2 times;

9, (ABC) {2,5} ABC appears at least two times, up to 5 times;

10. \\s+ one or more whitespace characters

11, Pattern.compile () can compile a regular expression to get a pattern object, the Pattern object has Matcher () method can match string, return a Matcher object, Matcher object has some methods:

(1) Find () returns a Boolean value that specifies that there is no match;

(2) Find (i) returns a match from the I position of the string to be matched;

(3) Group () returns the matching part;

(4) Group (i) returns the matching part of the first part of the regular expression to match the string;

(5) Start () end () returns the position of the matching part

Java Learning Note-4 regular expressions

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.