Learn Python and related technologies

Python Regex Tester and Compiler

A real-time python regex tester and playground. Type your regex pattern and test string below to see the matches and groups highlighted in real-time.

search find all full match
Flags: IgnoreCase Multiline DotAll Verbose
Match Result:

            Match Info:
            

Click highlighted text above to see its details here.

Note: This tool uses Python's regex engine. Ensure your patterns are compatible with Python's syntax.

Regex Cheat Sheet

pattern Character Description
\dMatches any digit
\DMatches any non-digit
\wMatches any word character (alphanumeric + underscore)
\WMatches any non-word character
\sMatches any whitespace character
\SMatches any non-whitespace character
^Matches the start of a line
$Matches the end of a line
.Matches any character except newline
*Matches 0 or more repetitions
+Matches 1 or more repetitions
?Matches 0 or 1 repetition
{n}Matches exactly n repetitions
{n,}Matches n or more repetitions
{n,m}Matches between n and m repetitions
[abc]Matches any character in the set (a, b, or c)
[^abc]Matches any character not in the set
(abc)Matches the exact sequence "abc"
|Acts as a logical OR between expressions
\bMatches a word boundary
\BMatches a non-word boundary
(?i)Case-insensitive matching
(?m)Multi-line matching, affecting ^ and $
(?s)Dot matches all characters, including newline
(?x)Verbose mode, allowing whitespace and comments in patterns
\Use to escape special characters
()Use parentheses for grouping and capturing
[]Use for character classes