Pygular

a Python regular expression editor

Fork me on GitHub

Match Groups

Match :

Match text


        
Pygular is a Python-based regular expression editor. It's a handy way to test regular expressions as you write them. To start, enter a regular expression and a test string. Or you can try an example.

Regex quick reference

[abc] A single character of: a, b or c
[^abc] Any single character except: a, b, or c
[a-z] Any single character in the range a-z
[a-zA-Z] Any single character in the range a-z or A-Z
^ Start of string, and in MULTILINE mode also matches immediately after each newline.
$ Matches the end of the string or just before the newline at the end of the string, and in MULTILINE mode also matches before a newline.
\A Start of string.
\Z End of string.
. Any single character except a newline. If the DOTALL flag has been specified, this matches any character including a newline.
\s Any whitespace character.
\S Any non-whitespace character
\d Any digit
\D Any non-digit
\w Any word character (letter, number, underscore).
\W Any non-word character
\b Matches the empty string, but only at the beginning or end of a word.
\b Matches the empty string, but only when it is not at the beginning or end of a word
\number Matches the contents of the group of the same number.
(...) Matches whatever regular expression is inside the parentheses, and indicates the start and end of a group.
(?:...) A non-grouping version of regular parentheses.
(?P<name>...) A named version of regular parentheses.
(?#...) A comment; the contents of the parentheses are simply ignored.
(?=..) Matches if ... matches next, but doesn't consume any of the string. This is called a lookahead assertion.
(?!...) Matches if ... doesn't match next. This is a negative lookahead assertion.
(?<=...) Matches if the current position in the string is preceded by a match for ... that ends at the current position. This is called a positive lookbehind assertion.
(?<!...) Matches if the current position in the string is not preceded by a match for .... This is called a negative lookbehind assertion.
(?(id/name)yes-pattern|no-pattern) Will try to match with yes-pattern if the group with given id or name exists, and with no-pattern if it doesn’t.
(a|b) a or b
a? Zero or one of a
*?, +?, ?? Makes '*', '+', and '?' qualifiers non-greedy
a* Zero or more of a
a+ One or more of a
a{m} Exactly m of a
a{m,} m or more of a
a{m,n} Between m and n of a
a{m,n}? As few as possible between m and n of a