Describe the intent, then trust but verify
The model translates a sentence like “match a US phone number with optional area code” into a working pattern — a huge time-saver when you know what you want but not the exact incantation. But a generated regex is a draft, not a guarantee. The discipline that separates a working pattern from a 2 a.m. incident is the verify step, which is why this tool puts a live test panel right under the output: paste real sample text and confirm the highlights match your expectation, including the strings that should be left alone.
The two failure modes worth knowing
Catastrophic backtracking (ReDoS). Patterns with nested or overlapping quantifiers can take exponential time on certain inputs. A pattern like (\d+)+$ looks innocent but can freeze on a long string of digits followed by a non-digit. If your regex will ever touch untrusted input, test it with a pathological string (e.g. 50 repeated characters) and rewrite nested quantifiers — usually you can make a sub-expression possessive or anchor it to avoid the blow-up.
Over-fitting to examples. A model shown “match emails like name@gmail.com” may emit a pattern that only accepts gmail.com, or one that’s far too permissive. The test panel is your defense: throw it addresses with plus-tags, subdomains, and new TLDs and watch what slips through.
When regex is the wrong tool entirely
Regular expressions are for regular patterns. Reaching for them on recursively-nested structures is a classic trap:
| Use regex for | Don’t use regex for |
|---|---|
| Emails, phone numbers, dates | Parsing HTML or XML |
| Log-line field extraction | Validating nested JSON |
| Find-and-replace patterns | Balancing brackets/quotes |
| Input format validation | Anything with arbitrary nesting |
For HTML, use a DOM parser; for JSON, parse it and inspect the object. A regex that tries to parse nested markup will be fragile no matter how cleverly it’s written.
Privacy and editing
Generation runs in your browser via a Web Worker, so your prompts and patterns stay private. If the model hallucinates a small syntax error, just fix it directly in the output box — a one-character correction is faster than re-prompting, and the test panel will confirm the fix instantly.