Toolvore

AI Regex Generator

Describe a pattern in plain English and get a regex.

This tool sends the text you enter to an AI provider to generate a response. Don't paste secrets or personal data. No files are uploaded.

Describe the pattern you want in ordinary words and get back a regular expression, with an explanation of what each part of it does.

How to use it

  1. 1Describe the pattern in the box — 'a UK postcode', 'dates written as DD/MM/YYYY', 'anything between two curly braces'.
  2. 2Press Generate Regex and read the code block, the part-by-part explanation and the sample matches below it.
  3. 3Copy the expression into the Regex Tester on this site and run it against your own strings — nothing is executed here.

Example

Input
Match a hex colour code, three or six digits, with the hash
Output
One anchored expression along the lines of ^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$, then a breakdown of the anchors, the character class and the alternation, then two or three sample matches.

The shape is dependable; the detail is not. Those sample matches are asserted by the model rather than executed, anchoring and case handling vary between runs, and the flavour defaults to JavaScript or PCRE unless you say otherwise — so a pattern bound for Python's re or for grep still has to be tested where it will actually run.

What happens to your data

The design keeps your data out of it by default: you describe the pattern instead of pasting the text you want to match, so in ordinary use the only thing leaving the page is a sentence about a shape. That sentence is still sent — appended to a fixed instruction line, posted to /api/ai and forwarded to Anthropic's Claude API, which is what composes the expression. Sample strings pasted in to sharpen the description travel with it, so invent those samples rather than lifting real email addresses, account numbers or log lines out of production.

Last updated August 2026

You know exactly what the strings look like — a reference that starts with two letters and runs to eight digits, a timestamp buried in a log line, every image tag in a template. What you do not want is twenty minutes spent recalling whether a dot needs escaping inside a character class. Describing the shape in a sentence and reading an expression back is faster, provided you know what to check afterwards.

Decide two things before you type. The first is the engine the pattern will run in. JavaScript, Python's re, Go's RE2, grep, PostgreSQL and Java differ exactly where it hurts — lookbehind, named groups, how \d treats non-ASCII digits, how many backslashes survive a string literal — and there is no dropdown here, so the flavour belongs in your sentence or you get JavaScript and PCRE by default.

The second is whether a regular expression is the right instrument at all. Anything that nests — HTML, JSON, balanced brackets, quoted fields containing the delimiter — is not something the formalism can express, and a pattern that appears to manage it is one that has not met the awkward input yet. A parser or a CSV library is the answer there, and describing the problem more clearly will not change that.

The mistake worth naming is treating the answer as finished. What comes back is a plausible first draft: it will usually handle the case you described and it will regularly be wrong at the edges — anchoring, greediness, case, Unicode, and the strings that ought not to match at all. Run it against your own data, including the near misses, before it goes anywhere near production.

How it works

Toolvore takes the one sentence you write, appends it to a fixed instruction line, and posts that to a route on the server, which forwards it to Anthropic's Claude API and streams the answer back into the page as it is written. The instruction the model works under asks for four things: the expression in a code block, a short explanation of each part, two or three example matches, and a note on the flavour where the flavour matters, with JavaScript and PCRE assumed otherwise. There is one box and no options, so anything the pattern must respect — the language, whether it should be anchored, whether case matters — has to be in that sentence. The honest weakness is that nothing here executes anything: no expression is run, on the page or on the server, so the example matches underneath are an assertion about the output rather than a test of it. The reply is capped at around 1,500 tokens, and one that reaches the ceiling ends with a bracketed note saying so rather than trailing off mid-word. A run can be stopped while it streams, and the finished text copied with one button.

Common use cases

  • Validating a reference, postcode or order number typed into a form
  • Pulling timestamps, status codes or IDs out of a log file
  • Writing a find-and-replace pattern for a search across a codebase
  • Building a redirect or routing rule that has to match a family of URLs
  • Tidying a column of inconsistently formatted phone numbers
  • Reading back an inherited expression nobody remembers writing
  • Turning a rough idea of a pattern into something you can then test properly

Frequently asked questions

Why does my regex work in an online tester but fail in my code?

Three things account for nearly all of it. The first is string escaping: in most languages a backslash inside a quoted string is itself an escape, so a pattern written as \d+ has to be typed as \\d+, or written with a raw-string form such as Python's r'' or a JavaScript literal between slashes. The second is flags — case-insensitivity, multiline and dot-matches-newline are switches the tester may have on and your code does not. The third is the engine: lookbehind, named groups and Unicode property classes are not available everywhere, and Go's RE2 omits backreferences and lookaround by design.

What is the difference between greedy and lazy quantifiers?

By default a quantifier takes as much as it can and gives ground only when the rest of the pattern fails, so .* swallows the whole line and reverses to the last possible closing character. Adding a question mark — .*?, +?, {2,5}? — makes it take as little as possible and grow only as needed. Neither is correct in general, and the symptom looks similar either way: one match far too long, or one that stops too early. Often the better fix is neither, but a negated character class such as [^<]* in place of the dot, so the quantifier cannot cross the boundary at all.

Why do people say never to parse HTML with a regular expression?

Because HTML nests, and a regular expression has no memory of how deep it currently sits. Pairing an opening tag with its own closing tag, when another of the same tag can appear between them, is beyond what the formalism expresses — you can approximate a fixed depth, and each layer makes the pattern longer and more fragile. Then come comments, attributes containing angle brackets, unclosed tags that browsers forgive, and case variation. A parser handles all of that as routine. Regular expressions are good on the flat parts of a document, such as a URL inside an attribute you have already extracted, and bad on its structure.

What is the correct regex for validating an email address?

There is not one, and chasing it is a reliable way to lose an afternoon. The grammar in RFC 5322 permits quoted local parts, comments and nesting that no sensible pattern covers, while the addresses people actually type are a much narrower set. Most working systems use something deliberately loose — something before an at sign, something after it, a dot somewhere in the domain — and then send a confirmation message, because delivery is the only test that shows an address exists. A stricter pattern buys little and rejects real people: newer top-level domains, plus-addressing and apostrophes in surnames are the usual casualties.

Where does the description I type actually go?

Unlike most of this site, this one does not run on your device. Your sentence is joined to a fixed instruction line, posted to a route on the server and forwarded to Anthropic's Claude API, which is what composes the expression. Your network address is read separately, and only to count requests against a per-address ceiling of six a minute. Nothing else here is readable — there is no field for the text you want to match and no upload — so the practical rule is to describe the shape and invent any sample strings you include. Real log lines, live keys and customer records have no reason to be in that sentence.

Can a regular expression hang a server?

Yes, and it is a recognised class of vulnerability rather than a curiosity. Most engines backtrack, and certain shapes — a quantifier nested inside another, or an alternation that can match the same text two ways — make the number of paths grow explosively with input length. A pattern that runs instantly on your examples can take minutes on a string of a few dozen characters chosen to defeat it, which is why it usually surfaces as requests timing out under load rather than as a wrong match. Keep patterns applied to user input simple and anchored, and prefer an engine with linear-time guarantees where you have the choice.

How do I make a pattern match across multiple lines?

Two separate switches get mistaken for each other. The multiline flag changes what the anchors mean: with it, ^ and $ match at every line break rather than only at the start and end of the whole string. The dot-matches-newline flag — called s or DOTALL, and written (?s) inline where no flag can be passed — changes what the dot covers, since by default it matches anything except a newline. Wanting a block that spans lines usually means the second, not the first. Line endings matter too: a file saved on Windows carries a carriage return before every newline, and it will sit inside your match unless you account for it.

Why does my pattern match part of the string instead of the whole thing?

Because a search finds the first place the pattern fits and, unless told otherwise, does not care what surrounds it — a pattern for four digits matches four digits sitting inside a longer number quite happily. Anchoring is the fix: ^ at the start and $ at the end require the entire string to be the match. The distinction also lives in the function you call. JavaScript's test and Python's re.search look anywhere, Python's re.match anchors only the start, and fullmatch is the one that demands all of it. Word boundaries, \b, are the softer version for when you want a whole word rather than a whole string.