Regular expression Basic syntax

Source: Internet
Author: User



The composition of regular expressions: qualifiers, atoms, meta-characters, quantifiers, module units and boundary control
Eg: mobile number:/^1[34578]\d{9}$/or/^1 (3|5|4|7|8) \d{9}$/
Floating point: \d+\.\d{2}$

1. The delimiter represents the beginning and end of a regular expression
"/" is generally used to denote the beginning and end of a regular

2. Atoms
|
is divided into "visible atoms" and "Invisible atoms", "visible atoms" refers to the UNICOCE encoded table in the keyboard output after the visible character of the inner Eye,
Otherwise, they belong to the invisible atom.
|
"Visible Atoms"
| 1) punctuation:;?. etc.
| 2) English alphabet, numbers A-Z 0-9
| 3) Chinese characters and other language characters
| 4) Physics company symbol
| 5) Other visible characters
|
"Invisible atoms"
|
| 1) line break \ n
| 2) enter \ r
| 3) tab \ t
| 4) Space
| 5) Other Invisible symbols

3. Meta-Characters
Effect: 1. Define how atoms are filtered 2. Atomic collation simplified regular expression character matching
1) Atomic Screening method
- | Match two or more branch selections
-[] matches any one of the atoms in the square brackets
-[^] matches any character other than the atom in square brackets

2) Atomic classification
- . Match any character except line break
-\d matches any decimal number, i.e. [0-9]
-\d matches any non-decimal number, i.e. [^0-9]
-\s match a non-visible atom
-\s matches a visible atom
-\w matches any number, letter, or underscore
-\w Match broadcast a non-digit, letter, or underscore

4. quantifiers
-{n} indicates that the atom in front of it appears exactly n times
-{N,} indicates that the atom in front of it appears at least n times
-{N,m} indicates that the atom in front of it appears at least n times at most m times
-* Match 0 times 1 times or more before the atom is {0,}
-+ matches 1 or more times its previous atom, i.e. {1,0}
- ? Matches 0 or 1 times its previous atom, {0,1}

5. Border control

^ Match string start position
$ match String End position

6. Module Unit
() match the whole of which is an atom

Matching mode

1. Greedy match (default)
2. Lazy Match

Correction mode
U-Lazy Match
I-ignore the case of English letters
X-Ignore whitespace
S-Let the element-free character '. ' Matches all characters in a line break

Usage:/Regular expression/uixs

Regular expression Basic syntax

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.