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