Nifty Tools

regex tester

Free regex tester for JavaScript patterns. Test matches, groups, flags, and replace previews in your browser with a worker timeout.

Processing mode: Local Browser-local

Flags

Matches

No matches yet.

Enter a JavaScript pattern and sample text, then click Test.

How to use it

Regex Tester — JavaScript, In Your Browser

  1. Enter a JavaScript regex pattern without surrounding slashes, choose flags, paste test text, and optionally add a replacement string.
  2. Click Test. The page starts a Web Worker, constructs `new RegExp(pattern, flags)`, runs the match loop and replacement preview, then terminates the worker when the result returns or the timeout is reached.
  3. Read the summary, inspect matches and groups, copy the results, or download them as `.txt`. Nothing uploads, and the page never claims a passing sample validates the pattern for production.

Good for

Common use cases

People reach for a regex tester when a pattern is almost right but the failure mode is invisible in the code that will eventually run it: an email-routing rule catches one address but misses another, a log parser extracts the timestamp but not the trace ID, a URL rewrite consumes too much of the path, or a CSV cleanup script captures the delimiter but drops a quoted value. The useful workflow is not "does this regex validate every possible real-world value" — no single sample panel can prove that. The useful workflow is "given the exact JavaScript pattern I plan to ship, which substrings match, what did each capture group contain, where are the match boundaries, and what would a replace operation output?" This page is intentionally scoped to JavaScript RegExp semantics because those are the semantics browser code, Node scripts, Cloudflare Workers, Vercel edge functions, and many no-code automation steps actually run. It does not pretend to be PCRE, Python, .NET, or RE2; flags, lookbehind, Unicode property escapes, named groups, and match indices follow the browser engine in the open tab. Running the test browser-locally matters for the same reason it matters on JSON, JWT, and hash tools: sample text often contains customer email addresses, log lines, URLs with tokens, internal hostnames, or incident notes that should not be pasted into a remote regex playground. The worker timeout is part of the product, not just a performance feature. Some regexes with nested quantifiers can trigger catastrophic backtracking on specific inputs, and a tester that runs the pattern on the main thread can lock the tab before it has a chance to warn you. This page runs the match loop in a worker and terminates it when it crosses the time budget, which gives you a clear "too slow for this input" signal without claiming the pattern is globally safe.

Processing mode

Browser-local

Files are processed by your browser. They never reach our servers.

Questions

Regex Tester — JavaScript, In Your Browser FAQ

Is this a JavaScript regex tester, or does it support PCRE, Python, .NET, and RE2 too?

It is a JavaScript regex tester. The page calls the browser's own `RegExp` constructor and `exec()` / `replace()` methods, so the result matches JavaScript semantics. That is the right scope for browser code, Node scripts, edge functions, many automation tools, and copy you are about to paste into a frontend form handler. PCRE, Python, .NET, Java, Ruby, and RE2 each have their own feature set and edge cases. A pattern that passes here may fail in one of those engines, especially around lookbehind, Unicode classes, backtracking behavior, inline flags, atomic groups, and named-group syntax.

Does a passing test mean my regex is valid and safe for production?

No. A passing test means the pattern compiled and matched the examples you gave it under JavaScript semantics. It does not prove the pattern accepts every valid input, rejects every invalid input, or performs well on adversarial strings. Treat the page like a debugging surface: it shows matches, groups, indices, and replacement output for sample text. Production safety still needs unit tests, negative cases, real fixture data, length limits, and in sensitive workflows a parser or dedicated validator instead of a regex.

How does the catastrophic-backtracking timeout work?

The match loop runs inside a Web Worker rather than on the main UI thread. The page starts a timer when the worker begins. If the worker does not return before the timeout, the main thread terminates it and reports that the pattern took too long for the sample input. This catches obvious slow-pattern failures without locking the page. It is still a sample-based check, not a formal proof: a pattern can pass this input and still be slow on a different input shape.

Which flags can I test?

The controls cover JavaScript's common flags: `g` global, `i` case-insensitive, `m` multiline anchors, `s` dotAll, `u` Unicode mode, `y` sticky, and `d` match indices. Browser support for a flag is determined by the engine running this page. If the engine does not support a flag or the pattern is invalid with that flag combination, the page shows the syntax error returned by `new RegExp()`.

Why do global and sticky matches sometimes behave differently?

The `g` flag keeps searching after each match. The `y` sticky flag only matches at the current `lastIndex`, which is useful when you are tokenizing text and every next token must start exactly where the previous one ended. If a sticky match fails at the current position, JavaScript stops. This page shows the same behavior, including the zero-length-match guard that advances the loop so a pattern like `.*?` cannot repeat forever.

Can I use this as a regex generator?

No. This page tests a pattern you write; it does not create one from a natural-language prompt. "Regex generator" is a different search intent and would need a different interface, probably with examples, constraints, and AI-assisted draft generation. Keeping this page as a tester avoids promising that a generated pattern is correct when the hard part is usually defining the edge cases.

Are my pattern and sample text uploaded anywhere?

No. The pattern, flags, sample text, replacement text, match results, and downloaded output all stay in your browser. The worker is a local browser worker created by this page; it does not send the input to a server. That makes the page appropriate for sample logs, URLs, tokens, email addresses, and incident snippets that should not be pasted into a remote playground.

Will this tool stay free?

The basic workflow is designed to stay free. Paid upgrades later will focus on bigger limits, batch work, OCR, saved presets, and ad-free use.