tools / regex test

Regex Tester

Test a regular expression against sample text — see matches highlighted with full match-position detail, or switch to Replace mode to preview a substitution live. Share link builds a URL that reopens to the exact same pattern and test string. Everything runs in your browser.

Pattern
/ /

Share link copies a URL with your pattern, flags, mode, and test string built in — opening it restores everything and re-runs it automatically. That data lives only in the link itself (nothing is ever sent to or stored on a server), so don't share a link built from a test string you wouldn't want visible to whoever you send it to.

Test string
Matches (highlighted)

What is a regular expression?

A regular expression (regex) is a pattern that describes a set of strings — used to search, validate, or extract text. Instead of matching one exact string, a regex can match "three digits, a dash, four digits" or "anything that looks like an email address" in a single compact pattern.

Common flags

  • g — global, find all matches instead of stopping at the first
  • i — case-insensitive matching
  • m — multiline, ^/$ match line boundaries, not just string boundaries
  • s — dotAll, lets . match newlines too

Highlight or replace

Highlight & match info shows every match inline plus a card per match with its exact character range and each capture group's value and range — useful for confirming a group like $2 captures exactly what you expect. Replace switches to a live preview of text.replace(pattern, replacement), so you can try a substitution — reordering captured groups, stripping a prefix, reformatting a date — before using it in code.

Frequently asked questions

What regex engine does this use?

Your browser's native JavaScript RegExp engine — the same one your code runs against if you're testing patterns for a JS or Node.js project. Other languages (Python, PCRE, Java) have small syntax differences.

Why do I see capture groups listed below the matches?

Parentheses in a pattern like (\d+)-(\d+) create capture groups — parts of each match you can extract individually. Each match card lists its captured groups with both their value and their exact character range, including named groups like (?<year>\d+), so you can see exactly what a reference like $1 or $<year> would contain.

Can I replace matched text, not just highlight it?

Yes — switch to Replace mode above the pattern field. Type a replacement using $1, $2 (or $<name> for named groups) to insert captured text, or $& for the whole match — the result updates live as you type, and a Copy button grabs it.

How does "Share link" work — is my test string sent to a server?

No. Your pattern, flags, mode, and test string are packed directly into the link's URL fragment (the part after #), which browsers never transmit to any server — the link is decoded and restored entirely by this page's own JavaScript when someone opens it. That also means the data travels wherever the link itself travels, so treat a share link the same way you'd treat pasting the test string somewhere directly.

Is my text uploaded when I use this tool?

No. Matching happens instantly in your browser using JavaScript's built-in regex engine — nothing is sent to a server.