Regex Tester + Cheatsheet
Test JavaScript regular expressions, inspect named groups, preview replacements, load common patterns, and get warnings for risky backtracking.
Regex status
Ready
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g
Matches shown
2
Showing the first 2 matches to keep the panel fast.
Performance risk
Low
Heuristic score: 0
Replace preview
Changed
6 numbered captures • 6 named captures
Editor
Runs with the browser's native JavaScript RegExp engine. Type a pattern, toggle flags, and test against any input.
Results
See live matches, capture groups, and the replacement output side by side.
Replace preview
Output changed after replacement.
Release 02/05/2026
Patch 15/06/2026Match list
Showing 2 matches2026-05-02Numbered groups
$12026$205$302
Named groups
year2026month05day02
2026-06-15Numbered groups
$12026$206$315
Named groups
year2026month06day15
Match extractor / export
List every match with its capture groups, then export the set as JSON or CSV.
Output is capped to keep the panel fast; turn off `g`/`y` or trim the input to see fewer matches.
{
"count": 2,
"truncated": true,
"matches": [
{
"match": "2026-05-02",
"index": 8,
"groups": [
"2026",
"05",
"02"
],
"named": {
"year": "2026",
"month": "05",
"day": "02"
}
},
{
"match": "2026-06-15",
"index": 25,
"groups": [
"2026",
"06",
"15"
],
"named": {
"year": "2026",
"month": "06",
"day": "15"
}
}
]
}Performance warnings
These checks are heuristic, not a full regex proof. They are designed to catch the most common catastrophic backtracking shapes before they freeze the tab.
No obvious backtracking traps were detected for the current pattern.
Common patterns library
Load a production-style pattern with sample input and a ready-made replacement template.
Quick cheatsheet
A compact refresher for the tokens and replacement helpers you reach for most often in JavaScript regex.
Flags
gFind every match instead of stopping at the first one.
iMake letter matching case-insensitive.
mLet `^` and `$` work per line instead of only at the start/end of the whole string.
sAllow `.` to match newline characters too.
uEnable Unicode-aware escapes and code point handling.
yMatch only from the current `lastIndex` position.
Anchors
^Start of string, or start of line with `m`.
$End of string, or end of line with `m`.
\bBoundary between word and non-word characters.
\BPosition that is not a word boundary.
Character classes
\dAny ASCII digit from 0 to 9.
\wWord character: letters, digits, and underscore.
\sSpace, tab, newline, and other whitespace characters.
[A-Z0-9_]Custom set: match one character from the listed range.
Quantifiers
*Repeat the previous token zero or more times.
+Repeat the previous token one or more times.
?Make the previous token optional.
{m,n}Repeat between `m` and `n` times.
Groups
(...)Create a numbered capture you can reuse in output.
(?<name>...)Create a named capture such as `year` or `slug`.
(?:...)Group tokens without creating a capture slot.
foo|barMatch either the left branch or the right branch.
Lookarounds
(?=...)Require the next characters without consuming them.
(?!...)Require that the next characters do not match.
(?<=...)Require previous characters without consuming them.
(?<!...)Require that previous characters do not match.
Replacement tokens
$&Insert the full matched text.
$1Insert capture group 1, 2, 3, and so on.
$<name>Insert a named capture replacement from the current match.
$`Insert the text that appears before the match.
$'Insert the text that appears after the match.
Notes
A few practical reminders that help when you're debugging real regexes.
- Named groups and replace preview use modern JavaScript syntax, so what you see here matches the browser `RegExp` engine.
- If you expect multiple matches, turn on `g`; otherwise JavaScript stops after the first successful match.
- Heuristic risk warnings are conservative. They are meant to keep the tester responsive, not to formally prove a regex safe or unsafe.