Test a regular expression pattern against a target string.
regular expression pattern cheat sheet
character matching
. any character
\w any word character (alphanumeric, underscore)
\W any character that is not a word character (alphanumeric, underscore)
\d any digit character (0-9)
\D any character that is not a digit character (0-9)
\s any whitespace character (space, tab, line break)
\S any character that is not a whitespace character (space, tab, line break)
character sets
[ABC] any single character in the set
[^ABC] any single character that is not in the set
[a-z] or [0-9] any single character in the given range
special characters
\t tab
\r carriage return
\n line break
escaped characters
\\ \
\. .
\+ +
\* *
\? ?
\^ ^
\$ $
\[ [
\] ]
\( (
}) (
\{ {
\} }
\| |
\/ /
\' '
\
$$ $
quantifiers
? optional - 0 or 1 of the preceding token
* 0 or more of the preceding token
*? 0 or more of the preceding token, but as few as possible before processing the next token
+ 1 or more of the preceding token
+? 1 or more of the preceding token, but as few as possible before processing the next token
{2} exactly 2 of the preceding token
{3,8} 3 to 8 of the preceding token
{3,8}? 3 to 8 of the preceding token, but as few as possible before processing the next token
anchors
^ the beginning of a string
$ the end of a string
\b word boundary position (whitespace, beginning or end of a string)
\B any position that is not a word boundary position
groups
(ABC) groups multiple tokens and create a capture group
(?:ABC) groups multiple tokens without creating a capture group
look around
(?=ABC) positive look ahead - match a group after the main expression without including it in the result
(?!ABC) negative look ahead - a group after the main expression which must not match
(?<=ABC) positive look behind - match a group before the main expression without including it in the result
(?<!ABC) negative look behind - a group before the main expression which must not match
alternative
| or - match expression before or after
replacing
$1 insert result of first capture group
$3 insert result of third capture group
$& insert matched substring
$` insert portion of string that precedes the match
$' insert portion of string that follows the match
Data privacy information:
Data is processed by the provider.