Regex Tester

Regex Tester

Updated August 27, 2026

This is JavaScript regex, not PCRE, not Python, not Go. A pattern that “worked in PHP” can fail here for reasons that look like your test string is wrong.

This is JavaScript regex, not PCRE, not Python, not Go. A pattern that “worked in PHP” can fail here for reasons that look like your test string is wrong.

Paste the pattern and a sample. Read the matches, not the vibes. If you needed lookbehind-on-Safari-old or POSIX classes, you’re in the wrong engine.

How to use it

  1. The flavor is JS (RegExp). No \A / \Z, no possessive quantifiers, no (?P<name>…). Named groups are (?<name>…).
  2. Flags matter. g changes lastIndex. Run twice without resetting and the second run looks like a miss. m makes ^/$ line-based. s makes . match newlines. i is unicode-aware in modern JS, not a simple ASCII fold.
  3. Catastrophic backtracking is real. Nested (a+)+ on a long near-match will freeze the tab. If it hangs, the pattern is the bug.

When it breaks

  • A / inside the pattern is fine in new RegExp('…') and a footgun in /…/ literals. This tester is the former.
  • \d is [0-9] in JS, not “any Unicode number” unless you opted into unicode sets.
  • Don’t debug a Python/Java pattern here and ship the “fix.” Test in the language that will run it.
0 chars 0 lines

Regular Expression

Enter your pattern below

/ /g

Pattern Flags

Active flags: /g

📚 Quick Reference

. any char
\d digit
\w word char
\s whitespace
^ start
$ end
* 0 or more
+ 1 or more

Features

  • JavaScript RegExp only (the flavor in browsers and Node)
  • Live match highlight with g i m s u flags
  • Capture groups listed with index and length
  • Shows a syntax error from `new RegExp`, not a PCRE diagnostic
  • Does not emulate Python, Go RE2, .NET, or POSIX

Common Use Cases

  • Debug a pattern that will run in the browser or in Node
  • See why lookbehind works here but failed in an old engine
  • Check that /g does not hide a lastIndex surprise
  • Prototype a validator before pasting it into application code

This is JavaScript regex, not PCRE, not Python, not Go

This is JavaScript regex, not PCRE, not Python, not Go. A pattern that “worked in PHP” can fail here for reasons that look like your test string is wrong.

Paste the pattern and a sample. Read the matches, not the vibes. If you needed lookbehind-on-Safari-old or POSIX classes, you’re in the wrong engine.

The flavor is JS (RegExp). No \A / \Z, no possessive quantifiers, no (?P<name>…). Named groups are (?<name>…). Flags matter. g changes lastIndex. Run twice without resetting and the second run looks like a miss. m makes ^/$ line-based. s makes . match newlines. i is unicode-aware in modern JS, not a simple ASCII fold.

Catastrophic backtracking is real. Nested (a+)+ on a long near-match will freeze the tab. If it hangs, the pattern is the bug.

Examples

Valid - JS named group (valid here)
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Invalid - Python named group (invalid in JS)
(?P<year>\d{4})
Invalid - PCRE possessive + (invalid in JS)
\d++
Valid - Lookbehind (JS; not in older IE, fine in modern engines)
(?<=@)\w+

Frequently Asked Questions

Can I test a Python or PHP (PCRE) pattern here?

This is JavaScript regex, not PCRE, not Python, not Go. A pattern that “worked in PHP” can fail here for reasons that look like your test string is wrong. The flavor is JS (RegExp). No \A / \Z, no possessive quantifiers, no (?P<name>…). Named groups are (?<name>…).

Why did a second run look like a miss?

Flags matter. g changes lastIndex. Run twice without resetting and the second run looks like a miss. m makes ^/$ line-based. s makes . match newlines. i is unicode-aware in modern JS, not a simple ASCII fold.

Why did the tab freeze?

Catastrophic backtracking is real. Nested (a+)+ on a long near-match will freeze the tab. If it hangs, the pattern is the bug. If you needed lookbehind-on-Safari-old or POSIX classes, you’re in the wrong engine.

Is this the same as Python or Java regex?

A / inside the pattern is fine in new RegExp('…') and a footgun in /…/ literals. This tester is the former. \d is [0-9] in JS, not “any Unicode number” unless you opted into unicode sets. Don’t debug a Python/Java pattern here and ship the “fix.” Test in the language that will run it.

Tips

  • If the pattern came from a Java, PHP, or Python codebase, assume it is PCRE-ish until you prove each construct exists in JS.
  • Avoid (a+)+b and similar nested greedy quantifiers on untrusted input.
  • Escape literal dots: host\.example\.com, not host.example.com.

Common Mistakes

A `/` inside the pattern is fine in `new RegExp('…')` and a footgun in `/…/` literals. This tester is the former.
`\d` is `[0-9]` in JS, not “any Unicode number” unless you opted into unicode sets.
Don’t debug a Python/Java pattern here and ship the “fix.” Test in the language that will run it.