Note: \ r \ n Indicates carriage return line, \ n = newline, \ r = Carriage return (but no line wrapping when output string)
- \d any number, any one of the 0~9;
\w any one letter or number or underscore, i.e. any of the a~z,a~z,0~9,_;
\s any of the white space characters, such as spaces, tabs, and page breaks;
The decimal point can match any character except the line break (/n);
\ t represents a tab character;
\b Matches a word boundary, that is, the position between the word and the space, does not match any character , each word is counted on both sides, only matches but does not replace, such as the character ABA Fhaud FAA in (/\b/g, "#") for #aba# #fhaud # #faa #;
^ matches where the string starts, does not match any characters
$ matches the place where the string ends, does not match any characters
- [] contains a series of characters that can match any one of these characters and can only be one. With [^] contains a series of characters, it is able to match any character other than the character.
[[email protected]] matches "a" or "B" or "5" or "@";
[^ABC] matches any character except "A", "B", "C"
[F-k] matches any one of the letters between "F" ~ "K"
[^a-f0-3] matches any character except "a" ~ "F", "0" ~ "3"
- {n} expression repeats n times, for example: "/w{2}" equals "/w/w"; "A{5}" equals "AAAAA"
{m,n} expression repeats at least m times and repeats up to n times, for example: "ba{1,3}" can match "ba" or "Baa" or "baaa"
{m,} The expression repeats at least m times, for example: "/w/d{2,}" can match "A12", "_456", "M12344" ...
Match expression 0 or 1 times, equivalent to {0,1}, for example: "A[CD]?" Can match "a", "AC", "AD"
+ expression appears at least 1 times, equivalent to {1,}, for example: "A+b" can match "AB", "AaB", "Aaab" ...
* expression does not appear or appear any time, equivalent to {0,}, for example: "/^*b" can match "B", "^^ ^b" ...
- The "or" relationship between the left and right sides of the expression
() The expressions in parentheses can be matched individually, in an expression that has an expression like |
JS Regular expression