Review of software architecture--about regular expressions in Java

Source: Internet
Author: User

Write in front:

This blog is written because of their own review of the "software construction" of the course, found that the regular expression of the relevant knowledge of the lack of mastery. So write down the blog in order to review and consolidate the relevant knowledge. If you find any mistake, please correct me, I would appreciate it.

PS: The depth of knowledge in the regular expression is based on the requirement of "software construction".

Regular Expressions:

Preface:

The regular expression defines the pattern of the string.

Regular expressions can be used to search, edit, or manipulate text.

Regular expressions are not limited to a single language, but have subtle differences in each language.

Characteristics:

1. Flexibility, logic and functionality are very strong;

2. Complex control of strings can be achieved quickly and in a very simple way.

3. For people who have just come into contact, it is more obscure and difficult to understand.

First, the common

1. \ marks the next character as a special character, text, reverse reference, or octal escape. For example, "n" matches the character "n". "\ n" matches the line break. The sequence "\\\\" matches "\ \", "\ \" ("Match" (".

2. ^ match the starting position of the input string.

3. $ matches the position at the end of the input string.

4. * 0 or more matches the preceding character or sub-expression.

5. + match the preceding character or sub-expression one or more times.

6.? Matches the preceding character or sub-expression 0 or one time.

7. {n} n is a non-negative integer. Matches exactly N times.

8. {n,} n is a non-negative integer. Match at least N times.

9. {n,m} m and n are non-negative integers, where n <= m. Matches at least N times, up to m times. Note: You cannot insert a space between a comma and a number.

X. x| y matches x or y.

One. [XYZ] Character set. Matches any one of the characters contained.

[^xyz] Reverse character set. Matches any characters that are not contained.

[A-Z] character range. Matches any character within the specified range.

[^ A-z] Reverse range character. Matches any character that is not in the specified range.

The. \d numeric character matches.

..................

.................. (There are many, but these are enough)

II. application points (for courses)

1. Whether the given string conforms to the filtering logic of the regular expression (i.e. "match");

2. Use regular expressions to get the specific part you want from the string.

Iii. Some simple examples (expressions)

1. Match URL: [a-za-z]+://[^\s]*

2.QQ (at least 5 digits, not starting with 0): [1-9][0-9]{4,}

3.((HTTP|FTP|HTTPS)://) ([a-za-z0-9\._-]+\.[ a-za-z]{2,6})

4. Email:^[a-zA-Z0-9_-][email protected][a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$

Write in the back:

These are my review of some of the knowledge involved (for the exam, not in depth), thank you for correcting me!

Review of software architecture--about regular expressions in Java

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.