Regex Tester
Write a regular expression, toggle the flags you need, and see exactly where it lands in your text. Match positions, capture groups, replacement previews, split output, and potential performance risks update together, with everything processed locally in your browser.
- Real-time syntax checking pinpoints the offending column the moment a pattern breaks
- Toggle the seven JavaScript flags g, i, m, s, u, y, and d to match how the engine will run
- Highlighted matches, captured groups, replacement preview, and split output stay in sync
- Built-in pattern templates and async ReDoS detection help avoid silent regressions
- Pattern, flags, and test text travel through a shareable link, so reviews and pairing stay frictionless
No matches yet. Try tweaking the pattern or flags.
Overview
This is not a one-off test() runner. Pattern editing, match positioning, replacement preview, split output, and performance risk sit side by side, so the rule lands right the first time.
- 01
Real-time syntax checks
Patterns are parsed with regexpp so syntax errors show up immediately with the offending column, instead of silently turning into empty matches.
- 02
Complete flag toggles
All seven JavaScript flags — g, i, m, s, u, y, and d — are exposed with names and short hints, instead of single letters you have to remember.
- 03
Highlighted matches and details
Every match is highlighted in the test text and listed in order with index, length, captured groups, and named captures.
- 04
Replacement and split preview
Run the same rule as a replacement or as a split, so logs, URLs, and configuration fields can be reshaped in one place.
- 05
Performance risk hints
The pattern is analysed asynchronously by recheck. When a catastrophic backtracking risk is found, an example attack input is shown.
- 06
Multi-language code export
Generate ready-to-paste regex code for JavaScript, TypeScript, Python, Go, PHP, and Java, with the right escaping applied for each target.
- 07
Shareable links
The pattern, flags, replacement, and test text are compressed into the URL hash, so colleagues can reopen the exact same workspace.
- 08
Fully local processing
Parsing, matching, replacement, and ReDoS detection all run in the current browser session — nothing is sent to a server.
How to use
Write a pattern, watch it land, refine the flags, then copy the literal, snippet, or share link.
- 01
Type your regex into the pattern field. Syntax issues will surface immediately with a column reference.
- 02
Toggle the flags you need. g, i, and m are the most common combinations.
- 03
Paste the text you want to test. Matches are highlighted as you type.
- 04
Inspect the match list on the right to confirm position, length, and capture groups.
- 05
Switch to the Replace tab when you need to rewrite the text using $1, $<name>, or $&.
- 06
Watch the performance hint in the corner; if a ReDoS risk shows up, rewrite the quantifiers.
- 07
Finish with Copy literal, Export code, or Copy share link to take the result with you.
Details
Different jobs care about different signals — match count, capture groups, performance, and code-ready output are all visible at once.
- The g flag scans the whole text and is the usual starting point for counting all matches.
- The i flag is the right pick for case-insensitive keywords, brand names, and log filters.
- The m flag anchors ^ and $ to each line for log files, Markdown headings, and line-based data.
- The s flag lets . cross newlines, which is handy for multi-line HTML or comment blocks.
- The u flag turns on Unicode mode so emoji, CJK text, and \u{...} escapes behave predictably.
- The y flag matches from lastIndex and is useful for hand-written lexers or block scanning.
- The d flag returns capture-group indices, which makes pinpoint highlighting much simpler.
- Match details are listed in order with start position and length, so capture groups stay easy to verify.
- The replacement panel understands $1, $<name>, $&, and $$ for flexible reshaping.
- The split output renders as a JSON array, perfect for debugging delimiter logic.
- ReDoS detection runs asynchronously and prints a reproducer when it finds a risky pattern.
- Exported code escapes the pattern correctly for each language and is safe to paste as-is.
Use cases
Most regex pain is not the idea — it is the constant copy, paste, and re-run loop, and the late discovery that a rule never matched at all.
-
Log and API field extraction
Pull IPs, user IDs, status codes, or timestamps out of logs and API responses with capture groups you can verify.
-
Form and input validation
Test validation rules against real samples before they ship — emails, phone numbers, identifiers, and custom codes.
-
Bulk content rewriting
Preview brand or URL replacements across long text bodies before letting the change land in production.
-
Code and SDK migration
Move legacy API calls, config keys, or syntax across versions while keeping dynamic parts captured.
-
Markdown and docs cleanup
Squash blank lines, normalise links, or extract sections so notes import cleanly into a new tool.
-
Security review and redaction
Surface potential leaks of tokens, emails, or phone numbers before publishing or sharing logs.
-
Config and script debugging
Nginx rewrites, CI scripts, webhooks, and IDE search rules all share regex flavours worth verifying first.
-
Learning and teaching
Walk through capture groups, lookarounds, and anchors with live highlights — great for pairing and reviews.
See also
Once the rule looks right, push the change through with Text Replace for full text bodies; if the data is line-based, Line Tools applies the same regex per line, while Text Cleaner tidies up the spacing afterwards. To confirm how much the change shortened or expanded the text, swing by Text Counter for a quick character, word, and byte comparison.
Best practices
Regexes are easy to write but hard to trust without a few small disciplines.
- Start with a short sample to validate the pattern, then expand. Edge cases surface earlier this way.
- Add anchors or word boundaries after quantifiers so the engine does not greedily swallow extra context.
- Watch for stacked quantifiers like (a+)+. Treat any ReDoS warning seriously and rewrite the pattern.
- Different engines escape backreferences, named groups, and Unicode classes differently. Re-test exported code in its target language.
- Keep a copy of the original text before running a destructive replacement, especially with the g flag.
- Share links carry the test text. Redact any sensitive content or replace it with a sample before sending.
Limitations
This tester mirrors JavaScript regex semantics, which is not the same as every other engine.
- Parsing and execution use the browser RegExp engine, so PCRE, Python, Go, and Java may behave differently.
- Exported snippets handle the necessary literal escaping, but complex patterns should still be re-tested in the target language.
- \b only counts ASCII word characters, so CJK and full-width text may need lookarounds to behave as expected.
- ReDoS detection has a fixed time budget. Very complex patterns may finish inconclusively and still deserve human review.
- The match list caps at 1000 entries for performance. Counts remain accurate, but only the first 1000 are listed.
- Live testing is not a replacement for production benchmarking on real data volumes.
FAQ
A few practical questions about flags, capture groups, performance, and code export.
My regex works here but fails in Python or Go. Why?
Engines differ on backreferences, Unicode classes, lookbehind, and named groups. This tool follows JavaScript RegExp. Treat exported snippets as a starting point, then re-test in the target language.
I enabled g but only see some matches listed.
The UI lists the first 1000 matches to keep the page responsive. Total counts remain accurate; only the per-row detail is truncated.
When should I enable u or v?
Turn u on whenever the pattern uses Unicode classes, \u{...}, emoji, or \p{...}. This tool exposes u directly. If your browser supports v (Unicode Sets), adjust the exported code manually.
The ReDoS indicator keeps showing checking. Why?
recheck runs with a time budget. Very complex patterns can exceed it. Simplify the regex, reduce nested quantifiers, or test with a smaller sample.
How do $1, $<name>, and $& work?
$& is the full match, $1, $2 reference numbered groups, and $<name> references named groups. Write $$ to keep a literal dollar sign.
Does the share link include the test text?
Yes. The pattern, flags, replacement, and test text are compressed into the URL hash. Redact sensitive content before sharing.
Why does a zero-width match sometimes freeze the engine?
Zero-width matches (such as ^, lookarounds, \b) can loop in some patterns. This tool detects that case, skips ahead, and shows a status note so the page keeps responding.
How large a body of text can this handle?
Tens to a few hundred thousand characters work well. Beyond that, split the text into chunks because highlighting cost grows with size.
I enabled g but replacement only changed one occurrence.
Replacement uses the configured flags. Confirm g is on. If only one match exists, loosen anchors or quantifiers.
Are named capture groups supported?
Yes. (?<name>...) groups show up under "Named groups" and can be referenced as $<name> in the replacement field.
Is my regex sent anywhere?
No. Parsing, matching, replacement, and ReDoS detection all run in the browser. Nothing leaves your session.
Can I save patterns?
Use Copy share link to capture the pattern, flags, and test text in a URL hash, then bookmark it or paste it into your notes.
Related tools
Once the rule is dialled in, the surrounding text tools cover replacement, line processing, cleanup, and length checks.