| Character Classes | |
| . | Matches any single character except the newline characters: \n \r \u2028 or \u2029. |
| \d | Matches a digit character in the basic Latin alphabet. Equivalent to [0-9]. |
| \D | Matches any character that is not a digit in the basic Latin alphabet. Equivalent to [^0-9]. |
| \w | Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to [A-Za-z0-9_]. |
| \W | Matches any character that is not a word character from the basic Latin alphabet. Equivalent to [^A-Za-z0-9_]. |
| \s | Matches a single white space character, including space, tab, form feed, line feed and other unicode spaces. Equivalent to [ \t\r\n]. |
| \S | Matches a single character other than white space (Not whitespace). Equivalent to [^ \t\r\n]. |
| \t | Matches a tab. |
| \r | Matches a carriage return. |
| \n | Matches a linefeed. |
| \v | Matches a vertical tab. |
| \f | Matches a form-feed. |
| [\b] | Matches a backspace. (Not to be confused with \b) |
| \0 | Matches a NUL character. Do not follow this with another digit. |
| \cX | Where X is a letter from A - Z. Matches a control character in a string. For example, /\cM/ matches control-M in a string. |
| \xhh | Matches the character with the code hh (two hexadecimal digits). |
| \uhhhh | Matches the character with the Unicode value hhhh (four hexadecimal digits). |
| \ | For characters that are usually treated literally, indicates that the next character is special and not to be interpreted literally. For characters that are usually treated specially, indicates that the next character is not special and should be interpreted literally. |
| Character Sets | |
| [xyz] | A character set. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen. For example, [abcd] is the same as [a-d]. |
| [^xyz] | A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen. For example, [^abc] is the same as [^a-c]. |
| Quantifiers | |
| * | Matches the preceding item 0 or more times. Default is greedy, non-greedy is *? |
| + | Matches the preceding item 1 or more times. Default is greedy, non-greedy is +? |
| ? | Matches the preceding item 0 or 1 time. Default is greedy, non-greedy is ?? |
| {n} | Where n is a positive integer. Matches exactly n occurrences of the preceding item. |
| {n,} | Where n is a positive integer. Matches at least n occurrences of the preceding item. Default is greedy, non-greedy is {n,}? |
| {n,m} | Where n and m are positive integers. Matches at least n and at most m occurrences of the preceding item. Default is greedy, non-greedy is {n,m}? |
| x|y | Matches either x or y. |
| Grouping and back references | |
| (exp) | Matches x and remembers the match. These are called capturing parentheses. |
| (?<name>exp) | (?'name'exp) | named substring |
| \n | Where n is a positive integer. A back reference to the last substring matching the n parenthetical in the regular expression (counting left parentheses). |
| \k<name> | A back reference to the named substring matching. |
| (?:exp) | Matches x but does not remember the match. These are called non-capturing parentheses. |
| (?=exp) | After text will match exp but not include this exp in the results (零宽断言) |
| (?<=exp) | Before text will match exp but not include this exp in the results (零宽断言) |
| (?!exp) | After text will NOT match exp and will not include this exp in the results (负向零宽断言) |
| ?(<!exp) | Before text will NOT match exp will not include this exp in the results (负向零宽断言) |
| (?#comment) | comment. |
| Boundaries | |
| ^ | Matches beginning of input. If the multiline flag is set to true, also matches immediately after a line break character. |
| $ | Matches end of input. If the multiline flag is set to true, also matches immediately before a line break character. |
| \b | Matches a zero-width word boundary. |
| \B | Matches a zero-width non-word boundary. |