Regex Tester – Free Online Regular Expression Tester & Debugger

Regex Tester & Debugger

Test, debug & build JavaScript regular expressions in real time. Live highlighting, capture groups, replace, split, explain, performance benchmarks, 20+ presets & cheat sheet.

🎯 Match ↔ Replace ✂ Split 💡 Explain ⚡ Benchmark
/ /
Test string 0 chars · 0 lines
📋 Paste 📄 Sample 🗑 Clear test ↺ Reset all
Highlighted matches
📋 Copy result ⬇ Export JSON ⬇ Export CSV 🔗 Share
📖 Regex Cheat Sheet — quick reference

Character classes

. any char (except newline)
\d digit · \D non-digit
\w word char · \W non-word
\s whitespace · \S non-ws
[abc] any of a, b, c
[^abc] NOT a, b, c
[a-z] range

Quantifiers

* 0 or more
+ 1 or more
? 0 or 1
{n} exactly n
{n,} n or more
{n,m} n to m
*?, +? lazy (non-greedy)

Anchors & boundaries

^ start of string/line
$ end of string/line
\b word boundary
\B non-word boundary
\A start of string
\Z end of string

Groups & alternation

(abc) capture group
(?:abc) non-capturing
(?<name>abc) named group
a|b a or b
\1, \2 back-reference
$1, $2 in replace

Lookarounds

(?=abc) positive lookahead
(?!abc) negative lookahead
(?<=abc) positive lookbehind
(?<!abc) negative lookbehind

Flags

g global (all matches)
i case-insensitive
m multiline
s dotall (. matches \n)
u unicode
y sticky
History (last 15)

How to Use the Regex Tester

  1. Type or paste a regular expression in the pattern field (no slashes needed — they're shown automatically).
  2. Toggle flags (g, i, m, s, u, y) using the checkboxes or type them in the flags box.
  3. Paste your test string below — matches highlight live as you type.
  4. Pick a mode: Match (find), Replace (substitute), Split, Explain, or Benchmark.
  5. Inspect capture groups, named groups, indices & full match details in the table below.
  6. Pick from 20+ presets (email, URL, phone, UUID, dates, IPs & more), copy results, or export as JSON/CSV.

What is a Regular Expression?

A regular expression (regex or regexp) is a pattern that describes a set of strings — used for searching, validating, extracting, replacing and splitting text. They're built into virtually every programming language and text editor.

This tool uses the JavaScript ECMAScript regex engine running natively in your browser, so behaviour is identical to RegExp in Node.js, V8, JavaScriptCore and SpiderMonkey. Patterns built here work the same in your JS/TS code. For PCRE/POSIX engines (PHP, Python, Java, Go), most syntax overlaps but a few features differ — see the cheat sheet.

Everything runs 100% client-side. Your patterns and test data never leave your device.

Common Use Cases

✅ Form validationBuild patterns for email, phone, postal codes, passwords.
🔍 Log file searchingExtract timestamps, IPs, error codes from server logs.
📝 Find & replaceBulk text substitution in IDEs, editors, scripts.
🕸 Web scrapingExtract URLs, emails, prices from HTML.
🧹 Data cleaningStrip whitespace, normalize phone numbers, fix CSV formatting.
🔐 Input sanitizationWhitelist/blacklist characters in user input.
🎓 Learn regexUse Explain mode to understand how patterns work.
⚡ Optimize patternsBenchmark mode catches catastrophic backtracking.
📊 CSV / TSV parsingSplit rows and fields with custom delimiters.
🛠 DevOps & sysadminBuild grep/sed/awk patterns visually.

Why Choose Our Regex Tester?

⚡ Real-time matchingMatches highlight as you type — no "Run" button needed.
🎯 5 modesMatch, Replace, Split, Explain & Benchmark in one tool.
📚 20+ presetsBattle-tested patterns for common validation tasks.
💡 Explain modePlain-English breakdown of your pattern's components.
⚙ All 6 flagsg, i, m, s, u, y — checkbox or keyboard.
📊 Capture group inspectorSee every group, named group, index, and length.
🔒 100% privateRuns in your browser. No upload, no logging.
📖 Built-in cheat sheetQuick reference for every regex token.
⚡ Performance benchmarkDetect catastrophic backtracking before production.
📜 HistoryLast 15 patterns saved with one-click restore.
🌙 Dark modeEasy on the eyes for long debugging sessions.
🖥 FullscreenDistraction-free workspace.
🔗 Share linkSend a URL that restores your pattern, flags & test string.
⬇ JSON / CSV exportSave matches for further analysis.
⌨️ Keyboard shortcutsCtrl/⌘+Enter to run · Esc to exit fullscreen.
🎨 Color-coded highlightsEach match group gets its own color.
📱 Mobile friendlyWorks great on phones & tablets.
♾ Free & unlimitedNo signup, no quotas, no ads in the workflow.
📐 Replace previewSee the post-replace text in real time.

Frequently Asked Questions

Which regex flavor does this tool use?

JavaScript / ECMAScript regex — the same engine that runs in browsers and Node.js. About 90% of syntax overlaps with Python, PHP/PCRE, Java, Go, Ruby, Perl. Differences: JS lacks possessive quantifiers (*+, ++) and atomic groups ((?>…)), but supports lookbehind, named groups (?<name>) and unicode property escapes.

What is "catastrophic backtracking"?

When a regex engine takes exponential time to fail-match certain inputs. Common cause: nested quantifiers like (a+)+ against input like aaaaaab. Use Benchmark mode — anything over ~100ms on a small test string is suspect.

Why doesn't my (?<=...) lookbehind work?

Lookbehind landed in ES2018. All modern browsers (Chrome 62+, Firefox 78+, Safari 16.4+) support it. If you're targeting older browsers, transpile or use a workaround with capture groups.

How do I match across line breaks?

Enable the s (dotall) flag — then . matches newlines too. Alternatively use [\s\S] or [^].

Can I use this regex in PHP / Python / Java?

Mostly yes — JS regex is a subset of PCRE. Watch out for: PHP requires delimiters (/pattern/flags), Python uses re.compile(r"pattern"), Java needs double-escaped backslashes (\\d instead of \d).

What's the difference between greedy and lazy quantifiers?

Greedy (*, +, {n,m}) matches as much as possible. Lazy (*?, +?, {n,m}?) matches as little as possible. Example on "<b>hi</b>": <.+> greedy matches the whole string; <.+?> lazy matches just <b>.

How do I reference capture groups in the replacement?

Use $1, $2, etc. for numbered groups; $<name> for named groups; $& for the whole match; $$ for a literal dollar sign.

Is my data sent anywhere?

No. Patterns and test strings are processed entirely in your browser using the native RegExp API. Nothing is uploaded.

Scroll to Top