| Regex Character |
Description |
| \ |
Escapes the next character to interpret it as a special character, a literal character, a back reference, or an octal escape character. For example, "n" matches the character "n". "\n" matches a newline character. The sequence "\\" matches "\", while "\(" matches "(". |
| ^ |
Matches the start position of the input string. If the multiline property of the RegExp object is set, ^ also matches positions following "\n" or "\r". |
| $ |
Matches the end position of the input string. If the multiline property of the RegExp object is set, $ also matches positions preceding "\n" or "\r". |
| * |
Matches the preceding sub-expression zero or more times. For example, zo* can match "z" and "zoo". * is equivalent to {0,}. |
| + |
Matches the preceding sub-expression one or more times. For example, zo+ can match "zo" and "zoo", but not "z". + is equivalent to {1,}. |
| ? |
Matches the preceding sub-expression zero or one time. For example, do(es)? can match "does" or "do" in "does". ? is equivalent to {0,1}. |
| {n} |
n is a non-negative integer. Matches exactly n times. For example, o{2} cannot match "Bob"'s "o", but can match both "o"s in "food". |
| {n,} |
n is a non-negative integer. Matches at least n times. For example, o{2,} cannot match "Bob"'s "o", but can match all occurrences of "o" in "foooood". o{1,} is equivalent to o+. o{0,} is equivalent to o*. |
| {n,m} |
m and n are both non-negative integers, with n<=m. Matches at least n times and at most m times. For example, o{1,3} matches at most three os in "fooooood". o{0,1} is equivalent to o?. Note that there should be no spaces between the comma and the two numbers. |
| ? |
When this character follows any other quantifier (*,+,?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. Non-greedy mode matches as few characters as possible, whereas the default greedy mode matches as many characters as possible. For example, for the string "oooo", "o+?" will match a single "o", whereas "o+" will match all "os." |
| . |
Matches any single character except for "\n". To match any character including "\n", use a pattern such as "(.|\n)". |
| (pattern) |
Matches the pattern and captures the match. The captured match can be obtained from the Matches collection produced, using the SubMatches collection in VBScript or the $0...$9 properties in JScript. To match parentheses characters, use "\(" or "\)". |
| (?:pattern) |
Matches the pattern but does not capture the result, which means this is a non-capturing match and does not store for later use. This is useful when combining different parts of a pattern using the "or" character "(|)". For example, "industr(?:y|ies)" is a more succinct expression than "industry|industries". |
| (?=pattern) |
Positive lookahead, matches a string at the beginning where the pattern matches. This is a non-capturing match, meaning the match does not need to be captured for later use. For example, "Windows(?=95|98|NT|2000)" matches "Windows" in "Windows2000", but does not match "Windows" in "Windows3.1". Lookaheads do not consume characters, meaning after a match occurs, the next search for a match begins immediately after the last match, rather than from the character following the lookahead. |
| (?!pattern) |
Negative lookahead, matches a string at the beginning where the pattern does not match. This is a non-capturing match, meaning the match does not need to be captured for later use. For example, "Windows(?!95|98|NT|2000)" matches "Windows" in "Windows3.1", but does not match "Windows" in "Windows2000". Lookaheads do not consume characters, meaning after a match occurs, the next search for a match begins immediately after the last match, rather than from the character following the lookbehind. |
| (?<=pattern) |
Positive lookbehind, similar to positive lookahead, but in reverse direction. For example, "(?<=95|98|NT|2000)Windows" can match "Windows" in "2000Windows", but will not match "Windows" in "3.1Windows". |
| (?<!pattern) |
Negative lookbehind, similar to negative lookahead, but in reverse direction. For example, "(?<!95|98|NT|2000)Windows" can match "Windows" in "3.1Windows", but will not match "Windows" in "2000Windows". |
| x|y |
Matches x or y. For example, "z|food" can match "z" or "food". "(z|f)ood" matches "zood" or "food". |
| [xyz] |
Character set. Matches any character contained within. For example, "[abc]" can match the "a" in "plain". |
| [^xyz] |
Negative character set. Matches any character not contained within. For example, "[^abc]" can match the "p" in "plain". |
| [a-z] |
Character range. Matches any character within a specified range. For example, "[a-z]" can match any lowercase letter character from "a" to "z". |
| [^a-z] |
Negative character range. Matches any character not in a specified range. For example, "[^a-z]" can match any character not in the range from "a" to "z". |
| \b |
Matches a word boundary, which is the position between a word and a space. For example, "er\b" can match "er" in "never", but cannot match "er" in "verb". |
| \B |
Matches a non-word boundary. "er\B" can match "er" in "verb", but cannot match "er" in "never". |
| \cx |
Matches a control character specified by x. For example, \cM matches a Control-M or carriage return. x must be one of A-Z or a-z. Otherwise, treat c as a literal "c" character. |
| \d |
Matches a digit character. Equivalent to [0-9]. |
| \D |
Matches a non-digit character. Equivalent to [^0-9]. |
| \f |
Matches a form feed character. Equivalent to \x0c and \cL. |
| \n |
Matches a newline character. Equivalent to \x0a and \cJ. |
| \r |
Matches a carriage return character. Equivalent to \x0d and \cM. |
| \s |
Matches any whitespace character, including spaces, tabs, form feeds, etc. Equivalent to [ \f\n\r\t\v]. |
| \S |
Matches any non-whitespace character. Equivalent to [^ \f\n\r\t\v]. |
| \t |
Matches a tab character. Equivalent to \x09 and \cI. |
| \v |
Matches a vertical tab character. Equivalent to \x0b and \cK. |
| \w |
Matches any word character including underscores. Equivalent to "[A-Za-z0-9_]". |
| \W |
Matches any non-word character. Equivalent to "[^A-Za-z0-9_]". |
| \xn |
Matches n where n is a hexadecimal escape value. The hexadecimal escape value must be exactly two digits long. For example, \x41 matches "A". \x041 is equivalent to \x04&1. ASCII encoding can be used in regular expressions. |
| \num |
Matches num where num is a positive integer. A reference to a captured match. For example, (.)\1 matches two consecutive identical characters. |
| \n |
Identifies an octal escape value or a backreference. If there have been at least n captured sub-expressions before n, n is a backreference. Otherwise, if n is an octal digit (0-7), n is an octal escape value. |
| \nm |
Identifies an octal escape value or a backreference. If there have been at least nm captured sub-expressions before nm, it is a backreference. If n at least has n captures before it, and m follows it, it is a backreference. If neither condition is met and both n and m are octal digits (0-7), nm matches the octal escape value nm. |
| \nml |
If n is an octal digit (0-3), and both m and l are octal digits (0-7), matches the octal escape value nml. |
| \un |
Matches n where n is a Unicode character represented by four hexadecimal digits. For example, \u00A9 matches the copyright symbol (©). |