Metacharacters |
Describe |
\ |
Marks the next character as a special character, or a literal character, or a backward reference, or an octal escape. For example, "\\n" matches \ n. "\ n" matches the line break. The sequence "\ \" matches "\" and "\ (" Matches "(". |
. Point |
Matches any single character except for "\ r \ n". To match any character that includes "\ r \ n", use a pattern like "[\s\s]". |
* |
Matches the preceding sub-expression 0 or more times (greater than or equal to 0 times). For example, zo* can match "Z", "Zo" and "Zoo". * Equivalent to {0,}. |
+ |
Matches the preceding subexpression one or more times (greater than or equal to 1 times). For example, "zo+" can Match "Zo" and "Zoo", but not "Z". + equivalent to {1,}. |
^ |
Matches the starting position of the input string. If the multiline property of the RegExp object is set, ^ also matches the position after "\ n" or "\ r". |
[A-z] [A-z] |
The character range. Matches any character within the specified range. For example, "[A-z]" can match any lowercase alphabetic character in the range "a" to "Z". Note: The range of characters can be represented only if the hyphen is inside a character group and appears between two characters; If the beginning of a character group, it can only represent the hyphen itself |
[^a-z] [^a-z] |
A negative character range. Matches any character that is not in the specified range. For example, "[^a-z]" can match any character that is not in the range "a" to "Z". |
[0-9] |
The number range. Matches any number in the specified range. For example, "[0-9]" can match any number in the range 0 to 9. |
[^0-9] |
Negative numeric range. Matches any character that is not in the specified range. For example, "[^0-9]" can match any character that is not in the range 0 to 9. |
\d |
Matches a numeric character. equivalent to [0-9]. |
N |
N is a non-negative integer. Matches the determined n times. For example, "o{2}" cannot match "O" in "Bob", but can match two o in "food". |
{N,} |
N is a non-negative integer. Match at least n times. For example, "o{2,}" cannot match "O" in "Bob", but can match all o in "Foooood". "O{1,}" is equivalent to "o+". "O{0,}" is equivalent to "o*". |
{N,m} |
Both M and n are non-negative integers, where n<=m. Matches at least n times and matches up to M times. For example, "o{1,3}" will match the first three o in "Fooooood". "o{0,1}" is equivalent to "O?". Note that there can be no spaces between a comma and two numbers. |
\D{4} |
Match 4 numeric characters |
X|y |
Match x or Y. For example, "Z|food" can match "Z" or "food". "(z|f) Ood" matches "Zood" or "food". |
[XYZ] |
The character set is combined. Matches any one of the characters contained. For example, "[ABC]" can Match "a" in "plain". |
[^XYZ] |
Negative character set. Matches any character that is not contained. For example, "[^ABC]" can match "Plin" in "plain". |