Self-understanding concept : Customize the rules to match exactly the characters or strings you want, while excluding characters or strings that you don't want to match.
Metacharacters
\b matches the beginning or end of a word, that is, the boundary of the word, is a position, its previous character and the latter is not all (one is, one is not or does not exist) \w, does not match the character such as delimiter.
Example: \bhello\b matches the word hello
. Matches any character except newline characters (\N,ASCII encoded as 10, hexadecimal 0x0a).
\d matches a digit (0,1,2,3, ...).
\s matches any whitespace character, including spaces, tabs (tab), line breaks (\ n), Chinese full-width spaces, and so on.
\w matches letters or numbers or underscores or kanji.
^ matches the start of the string.
$ matches the end of the string.
* Specifies that the preceding content can be reused any time (possibly 0 times).
Example:. * Any number of characters that do not contain line breaks
+ Specify + the previous content can be reused 1 or more times consecutively.
? Specify that the preceding content can be reused 0 or 1 times.
{n} specifies that the contents preceding {n} can be reused n times.
{N,} specifies {n,} before the contents can be reused n times or more times.
{N,m} Specifies that the contents of the preceding {n,m} can be reused N to M times.
[aeiou.?!] Matches any one of the characters inside the square brackets. Note that spaces can also be matched.
[0-9] exactly like \d; only English, [0-9a-za-z] and \w. Here is the specified character range method.
| Branching conditions, equivalent to or in Boolean algebra. Note that the regular expression begins to match from left to right, and if a branch is satisfied, the other branching conditions are no longer being taken care of.
Example: \d{5}-\d{4}|\d{5}, matching US zip code (9-digit or 5-digit number with a hyphen interval of 5-4). It is not possible to write the post branches in front.
() group. Specify the sub-expression with parentheses.
Example: IP address (2 (5[0-5]|[ 0-4]\D) | [01]?\d?\d] \.) {3} (2 (5[0-5]|[ 0-4]\D) | [01]?\d?\d]
\w matches any character that is not a letter, number, underscore, or kanji.
\s matches any character that is not a whitespace character.
\d matches any non-numeric character.
\b Matches a position that is not the beginning or end of a word.
[^x] matches any character except X.
[^aeiou] matches any character except the aeiou of these letters.
JavaScript Regular Expressions