- A regular expression matches some type of string by a specific formula. Match validation of strings or extract specific information from a large number of strings.
- Regular expressions contain ordinary characters and special characters. Most of the ordinary characters such as ' A ' or ' 0 ' can be simply matched to themselves. such as text can match ' text '. Special characters that can be used to match a set of strings, or to describe the use of characters.
- Feature characters include:
- . Matches any one character except \, such as CABCD in AB. can match ABC
- $ matches the end position of the string. (If the multiline property of the RegExp object is set, $ also matches the position before "\ n"), such as fol matching folked in 123folked, and fol$ matching fol
- ^ matches the starting position of the string (if the multiline property of the RegExp object is set, ^ can also match the position after "\ n")
- * Match 0 or more of the preceding sub-expressions, for example: ab* match A,ab or a after a successor to the B
- + match 1 or more of the preceding sub-, for example ab+ match A is greater than 0 B, so it cannot match only a
- ? Match 0 or 1 times in front of the sub, such as AB? Match A or AB
- *?,*?,?? is greedy, maximizing the match, for example, to match the
- {m} matches the string after the child repeats m times. For example: a{3} matches AAA, but cannot match other times a.
- {M,n} matches an M to n-th preceding subtype. A{3,}b matches the Aaab, or matches 100 times a one B.
- {m,n}? match minimized mode, a{3,5}b to Aaaaaab, match to Aaab.
Regular Expression Module re