Regex tester & explainer
Test a regular expression against sample text with live match highlighting and capture groups, read a token-by-token explanation of what your pattern does, and work through a short lesson for each category. JavaScript flavour, all in your browser.
gglobal — find all matchesiignore casemmultiline — ^ and $ match line breakssdotall — . matches newlinesuunicodeysticky — match from lastIndex only
2 matches.
shipped 2026-05, refunded 2025-12
- #12026-05[8–15]
- #22025-12[26–33]
| Match | Group | Value |
|---|---|---|
| #1 | 1 | 2026 |
| #1 | 2 | 05 |
| #1 | year | 2026 |
| #1 | month | 05 |
| #2 | 1 | 2025 |
| #2 | 2 | 12 |
| #2 | year | 2025 |
| #2 | month | 12 |
(?<year>start of a named capturing group "year"\dany digit (0–9){4}exactly 4 of the preceding token)end of the group-the literal character "-"(?<month>start of a named capturing group "month"\dany digit (0–9){2}exactly 2 of the preceding token)end of the group
Literals & the dotMatch exact text, and "any character"›
Most characters match themselves. A dot (.) matches any single character except a line break.
/c.t/gCharacter classesMatch one character from a set›
Square brackets match any single character listed inside. Use a range like a-z, or start with ^ to negate the set.
/[aeiou]/gShorthand classesDigits, word characters, whitespace›
\d is any digit, \w is any letter/digit/underscore, \s is any whitespace. Uppercase (\D \W \S) negates each.
/\w+/gAnchorsTie a match to a position›
^ anchors to the start, $ to the end, and \b to a word boundary. Anchors match a position, not a character.
/\bfox\b/gQuantifiersHow many times to repeat›
* is zero-or-more, + is one-or-more, ? is optional. Use {n}, {n,}, or {n,m} for exact counts.
/go+gle/gGreedy vs lazyMatch as few as possible›
Quantifiers are greedy by default — they grab as much as they can. Add a ? to make them lazy and stop early.
/<.+?>/gGroups & captureCapture part of a match›
Parentheses group tokens and capture what they match. Name a group with (?<name>...) to read it back by name.
/(?<year>\d{4})-(?<month>\d{2})/gAlternationMatch one option or another›
A pipe (|) means OR. Wrap it in a group to bound the choice to part of the pattern.
/(cat|dog|fish)/gLookaroundsMatch based on context without consuming it›
A lookahead (?=...) asserts what must follow; a lookbehind (?<=...) asserts what must precede. Neither is included in the match.
/\d+(?=€)/gClick any token to append it to your pattern (flags toggle on/off).
Runs entirely in your browser using the JavaScript RegExp engine. Other languages (PCRE, Python, Go RE2) differ in lookbehind support, named-group syntax, and atomic groups — see the history of the regular expression.