Regex Tester

Test, debug, and explain regular expressions.

  • Free
  • No signup
  • Files never leave your browser

How to use the regex tester

  1. Pick or write a pattern. The dropdown labelled Starter snippet… loads common patterns (email, URL, IPv4, ISO date, UUID, hex color) with a matching test string so you can see them work immediately.
  2. Toggle flags. Click the chips for g, i, m, s, u, y, d. Most users want g (find all) and sometimes i (case-insensitive).
  3. Edit the test string. Matches are highlighted inline and listed in a table with their index and groups.
  4. Switch modes. Match lists hits. Replace shows the substituted text — use $1, $2, $&, $<name> in the replacement. Split breaks the test string on every match.
  5. Read the explanation. The Explain pattern panel breaks your regex into tokens and describes each one in plain English. Useful for code review.

Cheat sheet

Anchors

TokenMeans
^Start of string (or line with /m)
$End of string (or line with /m)
\bWord boundary
\BNon-word boundary

Character classes

TokenMeans
.Any char except newline (newline too with /s)
\d \DDigit / non-digit
\w \WWord char [A-Za-z0-9_] / non-word
\s \SWhitespace / non-whitespace
[abc]Any of a, b, c
[^abc]Anything except a, b, c
[a-z]Range

Quantifiers

TokenMeans
*0 or more (greedy)
+1 or more (greedy)
?0 or 1 (greedy)
{n}Exactly n
{n,}At least n
{n,m}Between n and m
append ?Lazy variant of the above

Groups

TokenMeans
(...)Capture group
(?:...)Non-capturing group
(?<name>...)Named capture
(?=...) (?!...)Lookahead / negative lookahead
(?<=...) (?<!...)Lookbehind / negative lookbehind
\1 \k<name>Back-reference

Examples

Extracting key/value pairs

Pattern: (?<key>\w+)=(?<val>[^&]+) · flags: g

Test string: user=ada&role=admin&debug=1

Each match yields named groups key and val. Switch to Replace and use $<key>: $<val> to reformat.

Anonymizing emails

Pattern: [\w.+-]+@([\w-]+\.[\w.-]+) · flags: gi

Replacement: ***@$1

Result on Ping ada@example.com or Grace+test@dev.io: Ping ***@example.com or ***@dev.io.

Splitting CSV-ish input on commas with optional spaces

Pattern: \s*,\s* · flags: g · mode: Split

Test string: a , b,c, d["a", "b", "c", "d"].

Gotchas

  • \d matches non-ASCII digits with /u. Pure \d is [0-9] in JavaScript, but combined with /u it expands. Use [0-9] if you want ASCII-only.
  • . does not match newline by default. Add /s to include them, or use [\s\S] as a portable “anything” pattern.
  • Backslashes in strings. When testing a pattern that came from JS source code, remember the source had double-escaped backslashes — "\\d+" in code is \d+ here.
  • The lastIndex trap with /g. When reusing a RegExp object in code, its lastIndex advances. This tester creates a fresh RegExp on every keystroke, so you can ignore it here, but the bug bites in production.

Privacy and security

The regex tester is a single HTML page with a small JavaScript bundle. The pattern, flags, and test string never leave your device. The share link encodes state in the URL fragment (#…) — that part of a URL is not sent to servers. You can verify by opening DevTools → Network and watching for requests while you type.

  • JSON to CSV Converter — convert between JSON and CSV in your browser.
  • More coming soon: QR code generator with logo, image compressor. Bookmark this page or check back.

Frequently asked questions

What regex flavor does this use?

JavaScript (ECMAScript) regex via the V8 engine in your browser. That means: PCRE-like syntax with some differences. No possessive quantifiers, no atomic groups, no named conditionals. Lookbehind is supported in all modern browsers since 2021. Use the /u flag for full Unicode and the /d flag if you want exact match indices for groups.

What do the flags do?

/g matches all occurrences instead of stopping at the first. /i is case-insensitive. /m makes ^ and $ match line boundaries, not just string boundaries. /s lets . match newlines. /u turns on full Unicode mode (required for \\p{...} property escapes). /y is sticky — match must start at lastIndex. /d records the start and end index of each capture group.

How do I match a literal character that is also a metacharacter?

Escape it with a backslash: \\. for a dot, \\( for a paren, \\\\ for a backslash. Inside a character class only ] \\ ^ - need special handling; most other metacharacters become literal automatically.

My pattern hangs the page. What happened?

Catastrophic backtracking. Patterns like (a+)+ or (a|a)+b explode in complexity on inputs that almost-but-not-quite match. The tester warns you about common danger patterns, but the surest fix is to rewrite the regex without nested quantifiers — usually using possessive intent: (?:[^a]|a)+ instead of (.*)+ etc.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (* + ? {n,m}) try to match as much as possible, then back off if the rest of the pattern fails. Lazy versions (*? +? ?? {n,m}?) match as little as possible, then extend if needed. Example: <.+> matches "<b>x</b>" whole; <.+?> matches "<b>" and "</b>" separately.

Are my data and patterns sent to a server?

No. The whole tool runs in your browser tab. Open DevTools → Network and you will see no requests after the page loads. The share link encodes your state into the URL hash (after #), which the browser does not send to servers.

How do named capture groups work?

Use (?<name>pattern) to capture, and \\k<name> to back-reference. In replacement strings use $<name>. Example: (?<year>\\d{4})-(?<month>\\d{2}) on "2026-05" puts year=2026, month=05 in the named-groups list of each match.

Why does my pattern match an empty string?

Patterns that allow zero-width matches (like a*, \\b, ^) can fire at every position. The tester guards against infinite loops on zero-width matches, but you may see many ∅ entries — usually the fix is to add at least one required token (a+ instead of a*).

Can I save tests for later?

Click "Copy share link" to copy a URL that encodes the pattern, flags, mode, test string, and replacement. Bookmark it or paste into a doc. Nothing is stored on a server; the state lives in the URL.

Is this regex tester really free?

Yes. No signup, no account, no ads, no telemetry on your input. Use it as much as you like. Source is on the project repository.