Hunt
Skip to content

Regex Tester

Test a JavaScript regular expression against your text: matches are highlighted as you type, with every numbered and named group and its position. Try replacements with $1 and $<name>, and copy the pattern as a regex literal. It runs in your browser's own JavaScript engine, so the results are exactly what your code will get.

Runs in your browser

Test string

Matches are highlighted as you type

Matches

JavaScript's flavour

Regular expressions differ between languages. This tester uses the JavaScript engine of the browser you're using, so lookbehind, named groups, \p{…} Unicode properties and the v flag behave exactly as in your code. Patterns written for PCRE (PHP), Python or Java may need changes: JavaScript has no possessive quantifiers, atomic groups, \A or \Z, and names groups with (?<name>…) only.

How to use the Regex Tester

  1. Type a pattern, or paste a whole literal such as /\d+/g: its flags are picked up.
  2. Turn flags on or off.
  3. Type or paste the test string. Matches are highlighted and listed with their groups.
  4. Turn on Replace to try a replacement, and copy the result or the pattern as a JavaScript literal.

Examples

Named groups

Input
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g
Released 2026-11-10, patched 2026-11-24.
Output
2026-11-10  year=2026 month=11 day=10
2026-11-24  year=2026 month=11 day=24

Each match lists its named groups, which in code are match.groups.year and so on.

Reorder a date with a replacement

Input
/(\d{4})-(\d{2})-(\d{2})/g
Due 2026-11-10 and 2026-12-01.
Output
Due 10/11/2026 and 01/12/2026.

$1, $2 and $3 insert the groups in the order they appear in the pattern.

Emoji need the u flag

Input
/\p{Extended_Pictographic}/gu
Ship it 🚀 then ✅
Output
🚀
✅

Without u, \p{…} is a syntax error, and . would match only half of 🚀, which is two UTF-16 code units.

Flags

  • g finds every match instead of the first. Without it, match and exec stop at the first match.
  • i ignores case; m makes ^ and $ match at the start and end of each line.
  • s lets . match line breaks.
  • u treats the pattern as Unicode code points, so emoji count as one character and \p{Letter} works. v is its newer version, adding set operations such as [\p{Letter}--[a-z]]; use one or the other.
  • y (sticky) matches only at lastIndex; d adds the start and end of each group (match.indices).

Replacement patterns

In the replacement, $1 to $99 insert numbered groups, $<name> a named group, $& the whole match and $$ a literal dollar sign, as String.prototype.replace does.

Catastrophic backtracking

Some patterns take exponentially longer as the input grows, such as ^(a+)+$ on a long run of a followed by b. In a server, one such input can stall a process (a ReDoS attack). Here, the pattern runs in a background thread and is stopped after a few seconds, with a hint about what to look for: nested quantifiers and alternatives that can match the same text.

Options

Flags
g, i, m, s, u, v, y and d, as described above. Flags you type in the flags box or paste with a literal are kept in sync with the checkboxes.
Replace
Shows the text with every match (or the first, without g) replaced, using JavaScript's replacement patterns.

Limitations

  • Only JavaScript's regex flavour; features of PCRE, Python or .NET that JavaScript lacks are syntax errors.
  • Very new syntax (such as modifiers like (?i:…)) works only in browsers that support it.
  • Up to 5,000 matches are listed. A pattern that runs longer than 3 seconds is stopped.
  • Safari's engine has its own backtracking limit: it abandons a runaway pattern after a fraction of a second and reports no match, so the timeout message isn't shown there.

Frequently asked questions

Why does my regex work here but not in my code?

Check the flags (most often g or m), and escaping: in a string passed to new RegExp("…"), every backslash must be doubled, so \d becomes "\\d". Copy the pattern as a literal to avoid that.

Why does my global regex skip matches in a loop?

A regex with g or y remembers lastIndex between calls to test and exec. Reusing it on another string starts from the old position. Use matchAll, or reset lastIndex to 0.

What's the difference between u and v?

Both make the pattern Unicode-aware. v (newer) also allows set operations and properties of strings such as \p{RGI_Emoji}, and is stricter about escaping in character classes. They can't be combined.

Is my text sent to a server?

No. The pattern runs in a background thread in your browser; nothing you type is uploaded or logged.