Type a JavaScript pattern, flip the flags, paste a text. Matches and groups show up here, and nothing is sent to a server.
1
Type a pattern. The slashes around it are only decoration.
A regular expression is a pattern that describes a set of strings. This page runs that pattern with the JavaScript RegExp engine in your browser, the one defined by ECMA-262. It lists every match, the text of the match, where it sits in the text, and the captured groups, both numbered and named.
The engine here is JavaScript, not PCRE and not the .NET engine. A pattern that works on regex101 in PCRE mode can miss, or fail to compile, in this page. The flags on the switches are the JavaScript flags g , i , m , s and u .
m and s change on a text that contains line breaks. \d+ is the pattern. /\d+/g is not: the slashes and the flags would be searched as text. g is on when you open the page, so every match is listed. The other flags start off. $1 , $2 and any named group. An unmatched group is marked as such. pattern \d+ flags g text Order 42, item 7
42 index 6 7 index 15
pattern (?<year>\d{4})-(\d{2})-(\d{2})
text 2026-10-162026-10-16 index 0 year 2026 $2 10 $3 16
Indexes start at 0. In the first sample, Order is six characters, so 42 starts at index 6. 7 starts at index 15. In the date, the named group year is also group $1 . The page lists the number and the name.
\d+ on "Order 42, item 7" one match: 42
\d+ with g two matches: 42 and 7
Without g , the engine reports the first match and stops. With g , it continues after that match. It does not restart in the middle of the match it just found.
^item without m matches only the first line
^item with m matches at the start of each line
Without s , the dot matches any character except a line break. With s , the dot matches a line break too. ^ and $ still mean the start and end of the whole text until you turn m on.
\p{L} without u
matches the four characters p{L}\p{L} with u
matches one letter, including éd flag (hasIndices, ES2022). The page asks the engine for them. d does not change which text matches, so it is not one of the switches. a* on a text that has no a . The engine would otherwise stay on that index forever. After an empty match the page moves one character forward. y (sticky, ES2015) or v (unicodeSets, ES2024). v cannot be combined with u . Named groups, lookbehind and s arrived in ES2018. The name comes from Stephen C. Kleene. He described regular events in the 1951 RAND memorandum “Representation of Events in Nerve Nets and Finite Automata”, later printed in Automata Studies (Princeton, 1956). The algebra of those sets is what a regular expression denotes.
Ken Thompson published “Programming Techniques: Regular expression search algorithm” in Communications of the ACM, June 1968. That search was built into the QED editor, then into ed. The name grep is the ed command g/re/p : global, regular expression, print.
JavaScript grew the flags in public editions of ECMA-262: u and y in ES2015, s together with named groups and lookbehind in ES2018, d in ES2022, v in ES2024. A flag from one edition is a syntax error, or a different pattern, in an engine that does not have it yet.
g on. Without it the engine returns the first match, which is also what RegExp.prototype.exec does the first time you call it.