Regex Tester
Test JavaScript regular expressions against your text. See each match with its position, numbered groups and named groups.
Test JavaScript regular expressions against your text. See each match with its position, numbered groups and named groups.
Regular expressions describe text patterns. Writing them is easier when you can see matches as you edit.
Enter a pattern and flags, paste test text, and the tool lists every match with its index and capture groups. It uses your browser's JavaScript regular expression engine.
This tester uses the JavaScript RegExp engine, which is a backtracking matcher. It tries alternatives left to right and, when a later part fails, backs up and tries other options. Quantifiers such as star and plus are greedy by default and take as much as possible; adding a question mark after them makes them lazy. Capture groups are numbered by their opening parenthesis, named groups use the syntax question mark, less-than, name, greater-than, and non-capturing groups use question mark and colon.
Backtracking has a cost. Nested quantifiers such as (a+)+ applied to a long string that almost matches can take exponential time, known as catastrophic backtracking, and may freeze the page. Test patterns with realistic worst-case input, including long near-miss strings, before shipping them in server code or anywhere user-supplied text is matched. Also remember that dialects differ: JavaScript supports lookahead and, in modern engines, lookbehind, but has no possessive quantifiers, atomic groups or inline flags like PCRE does.
JavaScript (ECMAScript). Features differ in other languages like Python or PCRE.
g finds all matches, i ignores case, m makes ^ and $ match per line, s lets . match newlines, u enables Unicode, y is sticky.
Add the g flag to find all matches.
No. Matching runs in your browser.
Regex flavors differ. Named group syntax, lookbehind support, Unicode classes and flags vary between engines, so translate and retest the pattern in the target language.
Greedy quantifiers match as much text as they can, while lazy ones, written with a trailing question mark, match as little as possible. On a string holding two bracketed tags in a row, greedy .* spans both of them.