Skip to main content
Premier SEO Services

Developer tools

Regex Tester

Test a JavaScript regular expression against your text as you type: matches are highlighted, each capture group is listed, and a replace preview shows what $1 or $<name> produce.

  • Runs in your browser
  • Free, no sign-up
  • Unlimited use
  • Updated 30 September 2026

Regex Tester

Paste your text to see the numbers update live

  • JavaScript (ECMAScript) syntax. PCRE-only features such as possessive quantifiers and recursion aren't available.
  • A pattern that runs longer than 2 seconds is stopped and reported.

How to use the regex tester

  1. 1Type the pattern into Pattern, without the surrounding slashes, or pick one from Pattern library.
  2. 2Tick the Flags you need: g for every match, i to ignore case, m for per-line ^ and $, s so . matches new lines, u for Unicode.
  3. 3Paste your text into Test text. Matches are underlined in Matches, and Match details lists the position and every capture group.
  4. 4To try a substitution, tick Show a replace preview and type into Replace with, using $1 or $<name>. Press Copy to take the result.

Example

Input
Pattern: (?<user>[\w.+-]+)@(?<domain>[\w-]+(?:\.[\w-]+)+)   Flags: g
Text: Write to ada@example.com or grace.hopper@navy.mil.
Replace with: $<user> at $<domain>
Output
2 matches: ada@example.com (user = ada, domain = example.com), grace.hopper@navy.mil (user = grace.hopper, domain = navy.mil)
Replace result: Write to ada at example.com or grace.hopper at navy.mil.

Flags: g, i, m, s, u, y

FlagNameEffect
gglobalFind every match, not just the first. Replace changes all of them.
iignore casecat matches Cat and CAT.
mmultiline^ and $ match at the start and end of each line, not only of the whole text.
sdotAll. also matches line breaks.
uunicodeTreats emoji as one character and enables \p{L} style property classes.
ystickyEach match must start exactly where the previous one ended.

Without g, the tester shows only the first match, just as String.prototype.match would.

Capture groups and named groups

Parentheses capture what they match: in (\d{4})-(\d{2}), group 1 is the year and group 2 the month. Named groups make patterns self-documenting: (?<year>\d{4})-(?<month>\d{2}), read in code as match.groups.year.

  • (?:…) groups without capturing, for alternation or quantifiers: (?:https?|ftp)://.
  • \1 or \k<name> refers back to an earlier group inside the pattern: \b(\w+)\s+\1\b finds doubled words.
  • A group that didn't take part in a match is shown as (no match), which is different from an empty match.

Match details lists every group of every match (the first 500), with names in the column headers.

Replacing with $1 and named references

In Replace with, these sequences insert parts of the match:

WriteInserts
$1, $2 …the numbered group
$<name>a named group
$&the whole match
$'the text after the match (a dollar sign followed by a backtick gives the text before it)
$$a literal dollar sign

Example: pattern (\w+)@(\S+) and replacement $2/$1 turn ada@example.com into example.com/ada. Without the g flag only the first match is replaced, which the preview points out. For bulk edits on plain text without writing a pattern, use find and replace text.

Flavour differences: JavaScript, PCRE, Python

This tester uses your browser's JavaScript engine, so results match what RegExp does in Node.js and browsers. Most syntax is shared with PCRE (PHP, nginx, Apache) and Python's re, but not all:

  • Named groups: JavaScript and .NET write (?<name>…); Python writes (?P<name>…); PCRE accepts both.
  • Lookbehind: JavaScript allows any length; Python and most PCRE versions need a fixed length.
  • Inline flags: PCRE and Python accept (?i) at the start of a pattern. JavaScript only has the scoped form (?i:…), added in ES2025 and missing from older browsers, so use the flag checkboxes instead.
  • Possessive quantifiers and atomic groups (a++, (?>…)) exist in PCRE, not in JavaScript.
  • `\A`, `\Z`, `\h` are PCRE/Python; use ^, $ (without m) and [ \t] in JavaScript.

For .htaccess patterns, which are PCRE, the .htaccess tester runs rules against a URL.

Quick reference

TokenMatches
.any character except a line break (any at all with s)
\d \w \sdigit, word character ([A-Za-z0-9_]), whitespace
\D \W \Sthe opposites
\ba word boundary
[abc] [^abc] [a-z]one of, none of, a range
* + ?0 or more, 1 or more, 0 or 1
{3} {2,5} {2,}exactly, between, at least
*? +?lazy: as few as possible
^ $start and end (of each line with m)
(?=x) (?!x)followed by / not followed by x
(?<=x) (?<!x)preceded by / not preceded by x
\p{L}any letter in any script (needs u)

Alternation uses a vertical bar: cat|dog matches either word, and gr(a|e)y matches gray and grey.

Is my text private?

This tool runs entirely in your browser. Your text is not uploaded to our servers.

Sources

Questions about the regex tester

Which regex flavour does this use?

JavaScript (ECMAScript), run by your own browser. Patterns behave as they would in Node.js, Chrome, Firefox or Safari.

Why does my regex match too much?

Quantifiers are greedy: <.*> runs to the last > on the line. Make it lazy with <.*?>, or exclude the closing character: <[^>]*>.

How do I match a new line?

Use \n (or \r?\n for Windows line endings). To let . cross lines, tick the s flag; to make ^ and $ work per line, tick m.

What happens if my pattern hangs?

Matching runs in a background worker. If it takes more than 2 seconds, usually because of nested quantifiers like (a+)+, it is stopped and you see a warning instead of a frozen page.

Last updated 30 September 2026Maintained by Premier SEO Services

Report a problem