Regex Inverter

by Paul McGuire, January 2026

Description

This page allows you to invert a regular expression, generating strings that match it.

Instructions: Enter a regular expression in the "Regex" field and specify the maximum number of results you want to see (up to 100,000,000). Click "Invert" or press Enter to generate the matching strings.

Constraints:

Note: Complex regular expressions or those with large repetition counts may take some time to process.

Regular Expressions Quick Reference
ConstructDescription
.Any character except newline
\dDigit [0-9]
\wWord (identifier) character [a-zA-Z0-9_]
\sWhitespace character
\DNon-digit
\WNon-word character
\SNon-whitespace character
?0 or 1 repetition
{n}Exactly n repetitions
{n,m}Between n and m repetitions
{,m}0 to m repetitions
[...]Character class (any of these characters)
[^...]Negated character class
|Alternation (OR)
(...)Grouping
(?:...)Grouping (non-capturing)
(?P<name>...)Grouping (named group)
Other common regex features not covered in this utility
^Start of a line
$End of a line
\AStart of string
\ZEnd of string
*0 or more repetitions (use {,m} to limit repetitions)
+1 or more repetitions (use {1,m} to limit repetitions)
\bWord boundary
(?=...)Positive lookahead
(?!...)Negative lookahead
(?<=...)Positive lookbehind
(?<!...)Negative lookbehind

Examples

Here are some example regular expressions to try:

DescriptionRegex
Match one uppercase letter followed by three digits [A-Z]-\d{3}
Time of day (HH:MM:SS) (2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])
8-bit binary numbers [01]{8}
Integer from 0 to 99 [1-9]?\d
Integer from 0 to 255 25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d
Roman Numerals to 50 (X{,3}|XL)(I{,3}|IV|VI{,3}|IX)|L
Chemical Symbol A[cglmrstu]|B[aehikr]?|C[adeflmorsu]?|D[bsy]|E[rsu]|F[emr]?|G[ade]|H[efgos]?|I[nr]?|Kr?|L[airu]|M[dgnot]|N[abdeiop]?|Os?|P[abdmortu]?|R[abefghnu]|S[bcegimnr]?|T[abcehilm]|U(u[bhopqst])?|V|W|Xe|Yb?|Z[nr]
IPv4 addresses in 192.168.0.0/16 192\.168(\.((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d))){2}
MAC address [0-9A-Fa-f]{2}([:-][0-9A-Fa-f]{2}){5}
UUID [0-9A-F]{8}(-[0-9A-F]{4}){3}-[0-9A-F]{12}
Original US Area codes (leading and trailing digit 2-9, middle digit 1 or 0) [2-9][10][2-9]

Enter a regular expression to see its matching strings.

GitHub repo for this page regex-inverter

Powered by PyScript and pyparsing

packages = ["pyparsing"] [[fetch]] files = ["inv_regex.py"]