Regex Tester
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
- The flavor is JS (
RegExp). No\A/\Z, no possessive quantifiers, no(?P<name>…). Named groups are(?<name>…). - Flags matter.
gchangeslastIndex. Run twice without resetting and the second run looks like a miss.mmakes^/$line-based.smakes.match newlines.iis 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.
When it breaks
- A
/inside the pattern is fine innew RegExp('…')and a footgun in/…/literals. This tester is the former. \dis[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.
Regular Expression
Enter your pattern below
Pattern Flags
Active flags: /g
📚 Quick Reference
. any char\d digit\w word char\s whitespace^ start$ end* 0 or more+ 1 or moreFeatures
- 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
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?P<year>\d{4})\d++(?<=@)\w+Frequently Asked Questions
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>…).
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. If you needed lookbehind-on-Safari-old or POSIX classes, you’re in the wrong engine.
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.