Categories
regex

Reference – What does this regex mean?

52

What is this?

This is a collection of common Q&A. This is also a Community Wiki, so everyone is invited to participate in maintaining it.

Why is this?

is suffering from give me ze code type of questions and poor answers with no explanation. This reference is meant to provide links to quality Q&A.

What’s the scope?

This reference is meant for the following languages: , , , , , , .

This might be too broad, but these languages share the same syntax. For specific features there’s the tag of the language behind it, example:

  • What are regular expression Balancing Groups?

1

1135

The Stack Overflow Regular Expressions FAQ

See also a lot of general hints and useful links at the tag details page.


Online tutorials

Quantifiers

Character Classes

Escape Sequences

Anchors

anchormatchesflavors
^Start of stringCommon*
^Start of lineCommonm
$End of lineCommonm
$End of textCommon* except
$Very end of string*, D
\AStart of stringCommon except
\ZEnd of textCommon except
\ZVery end of string
\zVery end of stringCommon except
\bWord boundaryCommon
\BNot a word boundaryCommon
\GEnd of previous matchCommon except ,
TermDefinition
Start of stringAt the very start of the string.
Start of lineAt the very start of the string, and
after a non-terminal line terminator.
Very end of stringAt the very end of the string.
End of textAt the very end of the string, and
at a terminal line terminator.
End of lineAt the very end of the string, and
at a line terminator.
Word boundaryAt a word character not preceded by a word character, and
at a non-word character not preceded by a non-word character.
End of previous matchAt a previously set position, usually where a previous match ended.
At the very start of the string if no position was set.

“Common” refers to the following:

* Default |
m Multi-line mode. |
D Dollar end only mode.

Groups

Lookarounds

Modifiers

Other:

Common Tasks

Advanced Regex-Fu

Flavor-Specific Information

(Except for those marked with *, this section contains non-Stack Overflow links.)

General information

(Links marked with * are non-Stack Overflow links.)

Examples of regex that can cause regex engine to fail

Tools: Testers and Explainers

(This section contains non-Stack Overflow links.)

3

  • 3

    Related: the question for which an answer starts with “You can’t parse [X]HTML with regex.”.

    Jul 22, 2020 at 12:47

  • Perl has more ((?( for conditional, for example) but you can read the perl official documentation instead.

    Jan 29, 2021 at 7:50

  • 1

    Looks like Refiddle under the Tools section now points to some online casino site. Probably should be removed.

    Feb 1 at 13:27