There are two ways to create a regular expression:
- Literal quantity
1 var re =/ab+c/;
2. Call the constructor of the RegExp object
1 var re = RegExp ("Ab+c");
Second, special characters
- ^ Start of match input
- $ match end of input
- * Match a previous character 0 or more times
- + Match a previous character 1 or more times
- ? Match a previous character 0 or 1 times
- . Matches any single character except the beginning of a new line
- {n} repeats n times
- {n,m} repeats n-m times
- [ASD] A character set that fits any character
- [^ASD] anti-character set
- [\b] matches a push grid
- \d Match a number
- \d matches a non-numeric character
- \f Match a page break
- \ n matches a line break
- \ r matches a carriage return character
- \s matches a white space character, including spaces, tabs, page breaks, and line breaks
- \s matches a non-whitespace character
Regular expression of JavaScript