JavaScript Regex Tester
Test JavaScript regular expressions, flags, matches, captures, and replacements locally.
Enter a JavaScript pattern without / delimiters.
Flags and replacement options
Optional. Uses JavaScript String.replace semantics.
Examples
Pattern, flags, test text, and replacement stay in this browser. Nothing is uploaded or saved.
A regex match is not proof that data is valid, safe, authorized, or suitable for identity verification.
Set a pattern and test text, then run the pattern.
—Quick reference
Common tokens
.- Any character except line terminators
\d / \D- Digit / non-digit
\w / \W- Word character / non-word character
\s / \S- Whitespace / non-whitespace
^ / $- Start / end of input or line with m
* + ? {n,m}- Quantifiers
(...) / (?:...)- Capturing / non-capturing group
(?<name>...)- Named capture
\k<name>- Named backreference
(?=...) / (?<=...)- Lookahead / lookbehind
\p{L}- Unicode property; use u or v
JavaScript flags
d- Indices
g- Global
i- Ignore case
m- Multiline
s- Dot all
u- Unicode
v- Unicode sets
y- Sticky
How to use this tool
Pattern: cat\d+
Flags: g
Text: cat12 dog cat34Enter cat\d+ without enclosing slashes and select g to match both cat12 and cat34. Clear g to stop at the first match. To keep just the numbers, use cat(\d+) with replacement $1 to get "12 dog 34". If the pattern times out, test a shorter input and review repeated groups.
Read the regex quick reference →
Usage notes updated: JavaScript RegExp — MDN ↗
When not to use it
A match is not validation, authorization, or proof that identity, security, or untrusted input is safe.