RegEx Builder — Interactive Pattern Editor

Build a regular expression interactively. Type a pattern and get autocomplete suggestions; select text below to get pattern suggestions for it; matches and groups are color-coded in both the pattern and the test text, using the same color for each. Runs entirely in your browser.

Explanation

Replace

Common patterns

Export as code

Flag semantics don't map 1:1 across languages (e.g. JavaScript's g flag has no direct equivalent elsewhere — it's a different function call, not a flag). This is a reasonable starting point, not a guarantee of identical behavior — always test against your target language's actual engine.

FAQ

Why does the pattern breakdown use colors? Each capturing group gets its own color, used consistently in the pattern breakdown, the explanation list, and the highlighted matches below — so you can see at a glance which part of your pattern produced which part of the match.

How do the autocomplete suggestions work? They're based on common regex patterns (e.g. after typing \, common escape sequences are suggested; after a matchable token, quantifiers are suggested) — a heuristic, not an exhaustive grammar, so it won't catch every situation.

What does "select text for suggestions" do? Selecting a substring in the test string analyzes it (all digits? letters? looks like an email or date?) and offers regex snippets that would match similar text, plus the exact literal as a fallback.