Skip to main content
92 Nodes
All resources
Free tool

Regex Tester, Debugger & Code Generator

Build, test, and understand regular expressions, instantly.

Test JavaScript regular expressions with live match highlighting, capture groups, a replace preview, plain-English explanations, a test case builder, and ready-to-use code snippets for PHP, Python, Java, C#, Go, and Laravel — all generated locally in your browser.

Loading regex tester…
Basics

What is a regular expression?

A regular expression (regex) is a compact pattern language for matching, validating, or extracting text. Instead of writing custom string-parsing code, you describe a shape — “a digit, then a dash, then four more digits” — and the regex engine finds every place in your text that fits.

Regex shows up everywhere: form validation, search-and-replace in an editor, log parsing, URL routing, and data extraction. This tool runs the same JavaScript (ECMAScript) engine your browser and Node.js use, so what you see here behaves exactly like RegExp in your own JavaScript or TypeScript code.

Walkthrough

How to use the regex tester

  1. 1. Enter a pattern. Type or paste a pattern — either bare (\d+) or as a full literal with delimiters (/\d+/g), which is parsed automatically, including escaped slashes and slashes inside character classes.
  2. 2. Set your flags. Toggle g, i, m, and the rest as chips, each with a plain-language tooltip. Flags your browser doesn't support yet are disabled automatically.
  3. 3. Paste your test text.Matches highlight live, with a 150ms debounce, and evaluation runs in a background Web Worker with a timeout — so even a pathological pattern can't freeze the page.
  4. 4. Explore the tabs. Inspect match details and capture groups, preview a replacement, build a small test suite, read a deterministic explanation of your pattern, generate code for another language, or search the cheat sheet.
  5. 5. Export or share. Copy or download matches as JSON/CSV, download replacement output as text, export your test cases, or copy a share link — with a clear warning before including your test text in that link.
Reference

Regex flags explained

FlagNameMeaning
gGlobalFind every match instead of stopping after the first.
iIgnore caseMatch letters regardless of case.
mMultiline^ and $ match the start/end of each line.
sDot allLet . also match line breaks.
uUnicodeTreat the pattern as Unicode code points; enables \p{...}.
yStickyMatch only at the exact lastIndex position.
dMatch indicesRecord start/end indices for each capture group.
vUnicode setsNewer Unicode mode with set operations (can't combine with u).

The d and vflags are newer additions to JavaScript — this tool feature-detects support in your browser and disables them if they're unavailable. u and v cannot be combined, since v is a superset of u.

Safety

Catastrophic backtracking, and how this tool avoids it

Some pattern shapes — most commonly a quantifier nested inside another quantifier, like (a+)+$ — can make a regex engine try an exponential number of ways to match a string that ultimately fails. On a long enough input, that can look and feel like a frozen page.

Matching and replacing both run inside a dedicated Web Worker with a timeout of roughly 250–500ms. If a pattern doesn't respond in time, the worker is terminated and you'll see a clear message telling you to check for excessive backtracking — the page itself never locks up. The tool also scans your pattern for a couple of well-known suspicious shapes and shows them as heuristic warnings. These are hints, not a guarantee that a pattern is safe or unsafe.

Engine scope

JavaScript (ECMAScript) only

This tool evaluates patterns using your browser's native JavaScript RegExp engine — the same engine used by Node.js and every modern browser. It does not run a PCRE, Python, Java, .NET, Go, or Rust regex engine.

The code generator produces ready-to-copy snippets for other languages for convenience, along with compatibility notices where syntax or flag behavior is known to differ — for example, Python and Go both use (?P<name>...) instead of JavaScript's (?<name>...)for named groups, and Go's RE2 engine doesn't support lookaround or backreferences at all. Always verify generated snippets against your actual target runtime.

FAQ

Common questions

What is a regular expression?+

A regular expression (regex) is a small pattern language for describing text to search for, validate, or replace — used across virtually every programming language for things like extracting emails, validating form fields, or rewriting log lines.

Is this regex tester free?+

Yes, completely free, with no signup, account, or usage limit.

Is my test data uploaded anywhere?+

No. Your pattern and test text are evaluated locally in your browser, including inside a Web Worker for safety — nothing is sent to a server. Saved drafts live only in your browser's localStorage, and shared links encode everything in the URL itself, not in a database.

Which regex engine does this tool use?+

This tool uses the JavaScript (ECMAScript) RegExp engine built into your browser — the same engine that runs when you use regex in Node.js or client-side JavaScript. It does not execute PHP/PCRE, Python, Java, .NET, Go, or Rust regex engines; generated code snippets for those languages are for convenience and should be verified in their actual runtime.

What do regex flags mean?+

Flags change how a pattern is applied — for example g finds every match instead of just the first, and i ignores letter case. Hover or focus any flag chip in the tool for a plain-language description, or see the flag reference table below.

Why does my regex work in JavaScript but fail in PHP or another language?+

Regex syntax and flag behavior differ between engines. PHP's PCRE needs delimiters and has no 'g' flag (it uses preg_match_all instead); Python's re uses (?P<name>...) instead of (?<name>...) for named groups; Go's RE2 engine doesn't support lookaround or backreferences at all. The code generator shows these differences as compatibility warnings for each language.

What is catastrophic backtracking?+

It's when certain pattern shapes — commonly a quantifier nested inside another quantifier, like (a+)+ — cause the regex engine to try an exponential number of ways to match, effectively freezing on some inputs. This tool runs matching in a Web Worker with a timeout, so a runaway pattern can't freeze the page, and it also flags a few common suspicious shapes as heuristic warnings.

Can regex fully validate an email address?+

Not completely. The email preset here is a practical format check that catches the vast majority of real-world typos, not a full implementation of the RFC 5322 email specification, which is far more permissive (and stranger) than most patterns account for.

How do capture groups work?+

Wrapping part of a pattern in parentheses — (...) — captures whatever it matches so you can reference or extract it separately. Named groups, written (?<name>...), let you reference that piece by name instead of by position. The Matches tab lists both numbered and named groups for every match.

How can I replace matched text?+

Switch to the Replace tab, enter a replacement string, and it updates live. You can reference the whole match with $&, a numbered group with $1, a named group with $<name>, and more — replacement follows JavaScript's native String.replace() behavior exactly, including that the g flag is required to replace every match instead of just the first.

92 Nodes

Have a project in mind? Let's build it.

Tell us about your goals and we'll get back to you within one business day with next steps.

Book a free call