Test regular expressions live.
Generate regex from samples.
Regex syntax reference.
Explain regex patterns.
Test regex replacements.
Browse common regex recipes.
Visualize regex flow.
Search regex cheatsheet.
Convert cron expressions to regex.
[0] "matched text" at index 12, with a second line listing capture groups as a JSON array whenever the pattern contains parentheses.(\d{4})-(\d{2}) can look correct on screen while the first group silently swallows a different span than you intended. Seeing the group array printed next to the match is the fastest way to catch that.RegExp constructor with your pattern and the flags you toggled, then walks the subject text with matchAll(). Nothing is reimplemented, which is the most important fact about this tool: you are testing the exact engine that will run your pattern in production — V8's Irregexp in Chrome and Edge, SpiderMonkey in Firefox, JavaScriptCore in Safari.(?<name>...), and Unicode property escapes like \p{Letter} require the u flag. Possessive quantifiers and atomic groups do not exist, and neither do \A or \Z. A pattern pasted from a PHP or Python codebase frequently fails here for exactly those reasons — and it will fail in your JavaScript too, which is the point.matchAll(), an API that only exists for global regexes, so the tool appends g to your flag set internally. That is why the default flags read g and why results keep coming after the first match even if you toggle g off.String.prototype.indexOf returns. For text outside the Basic Multilingual Plane — emoji, some CJK extensions, mathematical alphanumerics — one visible character occupies two offsets, so an index of 14 may be the eleventh visible glyph.Invalid regex:. Those messages are precise and worth reading closely — Invalid regular expression: /a{2,1}/: numbers out of order in {} quantifier tells you the engine rejected the pattern before matching ever began.0 matches no matter how correct your pattern is.\d+). Enter the pattern body only. Do not wrap it in slashes and do not append flags here; a pasted /\d+/g becomes a literal slash match.g, i, m, s, u, y. Active flags render filled. Clicking one adds or removes it, and the set is re-sorted alphabetically after each click, so the toggle order does not matter.[0], showing the matched text in quotes and its start index. Patterns with capture groups add an indented groups: line holding the array of captured values.N match(es), or 0 matches. Use the copy control to take the whole report into a bug ticket or a code review comment.order 1042 shipped, order 2077 pendingorder (\d+) and leave the default g flag active. The report reads:[0] "order 1042" at index 0
groups: ["1042"]
[1] "order 2077" at index 20
groups: ["2077"]2 match(es). Both matches include the word order because the whole pattern is the match; only the parenthesised part became group one. If you want the numbers alone, capture the digits and ignore the full match — or change the pattern to \b\d{4}\b, which yields [0] "1042" at index 6 and [1] "2077" at index 26 with no groups at all.^order\s+(\d+) with only g active and you get one match, because ^ anchors to the start of the subject. Toggle m as well and the behaviour is unchanged here, since the subject is a single line; the moment your paste contains newlines, m is what lets ^ treat each of them as a separate beginning.\d here. In a JavaScript string literal the same pattern must be written "\\d", because the string parser consumes one backslash before the regex engine ever sees it. A pattern that works in this tester and fails in your file is almost always this.ana finds one match in banana, not two. If you need overlaps you must scan with an explicit advancing index instead.y is stricter than you may expect. With y active, every match must begin exactly where the previous one ended, so \d+ with gy only matches a run of digits at the very start of the subject.(a+)+$ tested against a long non-matching string can lock the tab. Prefer explicit alternatives and possessive-style rewrites such as (?:a+)+ avoidance, and test with the largest realistic input.s flag changes what a dot means. Without it, . will not cross a newline. A multiline pattern that quietly returns no matches is very often missing either s or m.u flag makes the engine stricter, not just smarter. It enables code-point semantics — surrogate pairs behave as one character — and simultaneously turns some previously tolerated escapes into syntax errors.RegExp engine. That is deliberate: it is the same engine your shipped JavaScript will use. Lookarounds and named groups work in current Chrome, Firefox and Safari. Possessive quantifiers, atomic groups (?>...) and Python's (?P<name>...) group syntax will not, and neither will \A or \Z.^ not match the second line of my input?m flag is off. Without it, ^ and $ treat the whole subject as a single string and anchor only at its absolute beginning and end./\d+/gi?\d+ goes in the Pattern field and the modifiers go in the Flags row. Tester fields take the bare pattern, without delimiters.m or s, or the pattern was copied with its slashes and flags still attached.