Home
Tester
Reference
About
Regex element quick search:
Character Classes
[
characters
]
Matches any character found in
characters
.
see an example
[^
characters
]
Matches any character not found in
characters
.
see an example
[
first
-
last
]
Matches any character in the range of characters from
first
to
last
.
see an example
.
Wildcard. Matches any character except
\n
.
see an example
\p{
category
}
Matches any character in a category of unicode characters, specified by
category
. To see what you can use for
category
, check out the
supported unicode general categories
and the
supported named blocks
.
see an example
\P{
category
}
Matches any character not in a category of unicode characters, specified by
category
. To see what you can use for
category
, check out the
supported unicode general categories
and the
supported named blocks
.
see an example
\w
Matches any letter, decimal digit, or an underscore.
see an example
\W
Matches any character except a letter, decimal digit, or an underscore
see an example
\s
Matches any white-space character.
see an example
\S
Matches any character except a white-space character.
see an example
\d
Matches any decimal digit.
see an example
\D
Matches any character except a decimal digit.
see an example
Character Escapes
\r
Matches a carriage return.
see an example
\n
Matches a newline.
see an example
\t
Matches a tab.
[\b]
Matches a backspace. Note that it must be enclosed in brackets to have this meaning.
\f
Matches a form feed.
\e
Matches an escape.
\v
Matches a vertical tab.
\a
Matches the bell character.
\
octal
Matches a character, where
octal
is the octal representation of that character.
see an example
\x
hex
Matches a character, where
hex
is the two digit hexadecimal representation of that character.
see an example
\u
unicode
Matches a unicode character, where
unicode
is the four digit hexadecimal representation of that unicode character.
see an example
\c
character
Matches an ASCII control character specified by
character
.
Anchors
^
Matches the beginning of the input.
see an example
$
Matches the end of the input, or the point before a final
\n
at the end of the input.
see an example
\A
Matches the beginning of the input. Identical to
^
, except it is unaffected by the multiline option.
see an example
\Z
Matches the end of the input, or the point before a final
\n
at the end of the input. Identical to
$
, except it is unaffected by the multiline option.
see an example
\z
Matches the end of the input, without exception.
see an example
\G
Matches the point that the previous match ended. Used to find contiguous matches.
see an example
\b
Matches any word boundary. Specifically, any point between a
\w
and a
\W
.
see an example
\B
Matches any point that is not a word boundary. Specifically, any point not between a
\w
and a
\W
.
see an example
Grouping Constructs
(
subpattern
)
Captures
subpattern
as an unnamed group.
see an example
(?<
name
>
subpattern
)
Captures
subpattern
as a named group specified by
name
.
see an example
(?<
name
-
previous
>
subpattern
)
Balancing group definition. This allows nested constructs to be matched, such as parentheses or HTML tags. The previously defined group to balance against is specified by
previous
. Captures
subpattern
as a named group specified by
name
, or
name
can be omitted to capture as an unnamed group. For more information, check out Morten Maate's tutorial on
matching nested constructs
.
see an example
(?:
subpattern
)
Noncapturing group. Allows the use of parentheses without
subpattern
being captured into a group.
see an example
(?
enabled
-
disabled
:
subpattern
)
Allows
subpattern
to be matched with different options than the rest of the pattern. Any inline option characters in
enabled
or
disabled
will enable or disable specific options, respectively. To see what inline option characters are available, check out
regular expressions options
.
see an example
(?=
subpattern
)
Zero-width positive lookahead assertion. Continues matching only if
subpattern
matches on the right.
see an example
(?!
subpattern
)
Zero-width negative lookahead assertion. Continues matching only if
subpattern
does not match on the right.
see an example
(?<=
subpattern
)
Zero-width positive lookbehind assertion. Continues matching only if
subpattern
matches on the left.
see an example
(?<!
subpattern
)
Zero-width negative lookbehind assertion. Continues matching only if
subpattern
does not match on the left.
see an example
(?>
subpattern
)
Prevents backtracking over
subpattern
, which can improve performance.
Quantifiers
*
Matches previous element zero or more times.
see an example
+
Matches previous element one or more times.
see an example
?
Matches previous element zero or one times.
see an example
{
n
}
Matches previous element exactly
n
times.
see an example
{
n
,}
Matches previous element at least
n
times.
see an example
{
n
,
m
}
Matches previous element at least
n
times and at most
m
times.
see an example
*?
Matches previous element zero or more times, but as few times as possible.
see an example
+?
Matches previous element one or more times, but as few times as possible.
see an example
??
Matches previous element zero or one times, but as few times as possible.
see an example
{
n
,}?
Matches previous element at least
n
times, but as few times as possible.
see an example
{
n
,
m
}?
Matches previous element at least
n
times and at most
m
times, but as few times as possible.
see an example
Backreference Constructs
\
number
Matches the value of a previously captured group, specified by
number
.
see an example
\k<
name
>
Matches the value of a previously captured named group, specified by
name
.
see an example
Alternation Constructs
|
Functions as a logical or. Matches any elements that it separates.
see an example
(?(
subpattern
)
yes
|
no
)
Treats
subpattern
as a zero-width assertion to check if it matches. If so, attempts to match with the
yes
subpattern. Otherwise, tries the
no
subpattern. The
|
no
part is optional.
see an example
(?(
group
)
yes
|
no
)
Checks if a previously defined group was succesfully captured, specified by
group
, which can be a number or a name for a named group. If so, attempts to match with the
yes
subpattern. Otherwise, tries the
no
subpattern. The
|
no
part is optional.
see an example
Substitutions
$
number
Substitutes the value of a group, specified by
number
.
${
name
}
Substitutes the value of a named group, specified by
name
.
$$
Substitutes the $ character.
$&
Substitutes the entire match.
$`
Substitutes all input text found before the match.
$'
Substitutes all input text found after the match.
$+
Substitutes the last group that was captured.
$_
Substitutes the entire input.
Miscellaneous
(?
enabled
-
disabled
)
Changes options in the middle of a pattern. Any inline option characters in
enabled
or
disabled
will enable or disable specific options, respectively. To see what inline option characters are available, check out
regular expressions options
.
(?#
comment
)
Inline comment, not evaluated as part of the pattern.
see an example
#
comment
End of line comment, not evaluated as part of the pattern. The Ignore Whitespace option must be enabled to use this.
see an example
No regex elements found that match your search term