All tools

Regex tester & explainer

Data

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.

New to regex? Read the guide — building blocks, flags, flavours, and the ReDoS footgun.
//g
  • gglobal — find all matches
  • iignore case
  • mmultiline — ^ and $ match line breaks
  • sdotall — . matches newlines
  • uunicode
  • ysticky — match from lastIndex only

2 matches.

Test string
Matches
2
shipped 2026-05, refunded 2025-12
  • #12026-05[815]
  • #22025-12[2633]
MatchGroupValue
#112026
#1205
#1year2026
#1month05
#212025
#2212
#2year2025
#2month12
Explanation
  • (?<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
Lessons
Literals & the dotMatch exact text, and "any character"

Most characters match themselves. A dot (.) matches any single character except a line break.

/c.t/g
Character 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]/g
Shorthand 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+/g
AnchorsTie 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/g
QuantifiersHow 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/g
Greedy 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.

/<.+?>/g
Groups & 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})/g
AlternationMatch 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)/g
LookaroundsMatch 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+(?=€)/g
Quick reference

Click 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.