piapia123
en

Regex Tester

Text

Everything runs locally in your browser — nothing is uploaded

TEST TEXT
MATCHES
CAPTURE GROUPS
REPLACE PREVIEW
CODE

COMMON PATTERNS

Matching and replacing happen locally in your browser — neither the pattern nor the text is uploaded.

Build a regular expression in the browser: matches highlight as you type, capture groups including named ones are listed one by one, and entering a replacement previews the whole text rewritten. The tool also guards against catastrophic backtracking — a pattern such as (a+)+ can lock a browser tab for seconds on long input, so it is detected up front, refused on long text, and the reason is spelled out instead of pretending the scan finished. Once the pattern behaves, generate the equivalent JavaScript, Python, Java, Go or PHP code: flags are translated one by one (outside JavaScript, g is not a letter but a choice of API) and the backreference syntax in your replacement is converted too — Python wants \1 where JavaScript wants $1, and getting that wrong silently produces the wrong output.

Features

  • Live highlighting of every match, with zero-width matches such as \b and (?=x) marked in place
  • Capture group table showing group number, name and value; groups that did not participate are left visibly empty
  • Replace preview supporting $1, $& and $<name>, always previewed globally
  • Generate JavaScript, Python, Java, Go or PHP code, with pattern escaping, flag translation and the right global-matching call
  • Backreferences in the replacement are converted per language (Python uses \1, the rest use $1) instead of pasting $1 into a result verbatim
  • Go's regexp engine is RE2: no lookaround and no backreferences. Such patterns get an explicit warning instead of code that will not compile
  • Individual g / i / m / s / u flag toggles that behave exactly like the JavaScript engine
  • ReDoS guard: nested quantifiers and quantified alternations stop execution on long input with an explanation
  • Honest limits: input past 100,000 characters, more than 2,000 matches or a scan over 120 ms are all reported
  • A cheat sheet of common patterns (email, URL, IPv4, dates, times, CJK, phone numbers, colours, tags) that fills in along with sample text

How to use

  1. Type your pattern between the slashes and tick the flags you need
  2. Paste test text on the left — matches highlight as you type
  3. Enter a replacement string to preview the rewritten text below
  4. Pick a target language and the Code panel hands you an equivalent implementation to paste
  5. Click a cheat sheet entry to load it and see it work immediately

FAQ

Why did my pattern return nothing?
If the text is long and the pattern contains nested quantifiers such as (a+)+ or (\d+\s?)*, the tool stops and tells you. Those patterns backtrack exponentially on long input and would freeze the tab for seconds. Verify with short text first, or rewrite the pattern without nesting.
Why does it say the global flag is off?
Without g, JavaScript returns only the first match. That is the engine behaving normally, and the tool reports it rather than quietly adding g — otherwise a pattern that works here would behave differently once pasted into your code.
Is long input truncated?
Yes. Past 100,000 characters only the first part is scanned, and the page says so plainly. A synchronous regex cannot be interrupted once it starts, so limiting the input size is the only reliable protection.
Can I use the generated code as-is?
Yes, with two things worth checking per language. First the flags: outside JavaScript, g is not a letter but a choice of API — Python uses findall, Java needs a while (matcher.find()) loop, Go uses FindAllString — and the generated code already does that. Second the backreference syntax in the replacement: JavaScript writes $1, Python writes \1, and the conversion happens for you. If the pattern uses lookaround or a backreference and you pick Go (whose engine is RE2), a warning appears above the code, because that pattern will not compile there.
Is my pattern or text uploaded?
No. Matching and replacing run entirely in your browser, the page makes no network requests, and it keeps working offline.

Related tools