Developer

Regex tester

Build and test JavaScript regular expressions with live match highlighting and capture-group breakdowns. Six flags, five sample patterns, and built-in protection against runaway test inputs. Runs entirely in your browser.

PATTERN
/ / Flags

Pattern between the slashes; toggle flags on the right. Hover any flag to see what it does.

TEST STRING
TEST INPUT
HIGHLIGHTS
MATCHES capture groups inline
Try:
Everything runs in your browser. Nothing is sent to any server.

What is a regex tester?

A regex tester compiles a regular expression in real time and shows you exactly which substrings of your test input match — including the indices, lengths, and any capture groups. It's the fastest way to iterate on a tricky pattern without round-tripping through your editor and runtime each time.

What do regex flags do?

Each flag changes how the engine matches: <code>g</code> finds all matches (without it you only get the first), <code>i</code> ignores case, <code>m</code> makes <code>^</code> and <code>$</code> match per line, <code>s</code> lets <code>.</code> match newlines, <code>u</code> enables Unicode-aware matching, and <code>y</code> anchors the match to lastIndex.

Avoiding catastrophic backtracking

Patterns with nested quantifiers like <code>(a+)+b</code> can take exponential time on certain inputs — the engine tries every possible split before giving up. This tester caps inputs at 100 KB and tries to abort after 100 ms, but you should never trust user-supplied patterns server-side without a strict timeout. Prefer linear-time engines (RE2, Hyperscan) where possible.

Got a JSON response to dig into? Try our JSON formatter.

Common Uses

  • Email validation: Build a pragmatic email regex you actually understand — full RFC 5322 is huge, and most apps need just the common-case shape.
  • Log line extraction: Pull request IDs, error codes, or timestamps from server log lines for grepping and metrics.
  • Form input scrubbing: Validate phone numbers, postcodes, or product SKUs before sending to your backend API.
  • Search-and-replace authoring: Iterate on a find/replace pattern in this tester before pasting it into VS Code's regex search.
  • Slug/URL pattern matching: Build URL routing patterns with named capture groups to extract path segments cleanly.
  • CI lint configuration: Test patterns destined for ESLint --fix rules or pre-commit hooks before committing the config.
  • Data cleaning at scale: Pilot a regex on a sample slice of CSV before running it across millions of rows in your ETL job.

FAQ

What does the g flag mean?

The "global" flag tells the engine to find every match instead of stopping at the first. Without it, methods like .match() return only the first match. Some methods (.matchAll, .replaceAll) require it; others throw if it's missing.

What's a capture group?

Parentheses in a regex create a capture group — the engine remembers what matched inside them so you can extract that part. Use (?…) for named groups, accessible via match.groups.name. Use (?:…) for a non-capturing group when you only need to apply a quantifier.

Lookahead vs lookbehind — when to use each?

Lookahead (?=…) checks that what follows matches a pattern, without consuming it. Lookbehind (?<=…) does the same backwards. Use them to assert context without including it in the match — e.g. matching "$" only when followed by a digit, or only when preceded by "USD".

Why is my regex slow / hanging the page?

Likely catastrophic backtracking — the engine tries exponentially many ways to match a pattern with nested quantifiers. Common culprits: nested + or *, alternation between similar sub-patterns. Rewrite with possessive quantifiers (where supported) or refactor to be greedy-then-lazy.

Does this tool send my regex anywhere?

No. The regex compiles and runs entirely in your browser. The pattern and flags are saved to localStorage so they survive a refresh, but the test string is never persisted — it can contain anything sensitive (logs, customer data, paste-from-anywhere).

By the Numbers

Sources & Further Reading

01
Runs on your device
Files never leave your browser. No server uploads.
02
8 languages
EN, ES, HI, PT, FR, DE, ID, JA — every tool.
03
No signup
Open the page, use the tool. That's it.