Live pattern explanation
Select or hover a token to connect it to the expression. Explanations are a debugging aid; the browser remains the authority on valid syntax.
/\w+/gi are detected safely. Use single backslashes here.Ranges use JavaScript UTF-16 code-unit indices. When astral Unicode characters change the count, code-point positions are also shown.
Select or hover a token to connect it to the expression. Explanations are a debugging aid; the browser remains the authority on valid syntax.
Each preset loads a pattern, flags and realistic test text. Expected results describe this exact sample, not universal validation.
Regex literals escape forward slashes. Constructor strings also escape backslashes and quotes because the pattern passes through JavaScript string syntax first.
Add strings that should match or should not match, then run them together to catch regressions.
Turn on g. Without the global flag, JavaScript stops after the first match.
^ and $ restrict a match to an entire input, or to each line with m. Remove or narrow anchors when searching within longer text.
Greedy quantifiers take as much as they can. Prefer a precise character class or a lazy form such as .*?, while still giving it a clear boundary.
Escape metacharacters such as ., +, ?, ( and [ with a backslash. Constructor strings need the backslash escaped again.
m changes ^ and $; it does not make dot span lines. Use s for dotAll behavior.
This page uses ECMAScript. Atomic groups, branch reset groups, inline mode modifiers and some other flavor-specific constructs are not JavaScript syntax.
Use (?<name>...) and refer to it with \k<name> in a pattern or $<name> in a replacement.
Without Unicode mode JavaScript commonly operates on UTF-16 code units, not Unicode code points. Even with u, indices remain code-unit offsets; this inspector shows code-point positions when they differ.
This tester uses the native JavaScript RegExp engine in your browser, following ECMAScript syntax rather than PCRE, Python or another regex flavor.
No. Patterns, test text, replacements and test cases are processed locally in your browser and are never sent to Starlight Tools.
g finds all matches, i ignores letter case, m makes ^ and $ work per line, s lets dot match line breaks, u enables Unicode-aware parsing, y matches only at lastIndex, and d returns match indices.
Common causes are an unclosed group or character class, an invalid escape, a repeated quantifier, or syntax from another regex flavor. The error shown comes from your browser's RegExp constructor.
Enable the global g flag to continue searching after the first match. It is enabled by default in this tester.
Parentheses capture parts of a match as numbered groups. Use (?<name>...) for a named group and (?:...) when grouping without capturing.
Modern JavaScript engines generally support positive (?<=...) and negative (?<!...) lookbehind, but the tester feature-detects support because older browsers may reject it.
In replacement text, $& inserts the whole match, $1 and $2 insert numbered groups, and $<name> inserts a named group. Use $$ to insert a literal dollar sign.
Regex flavors have different syntax and features. JavaScript does not support every PCRE or Python construct, and constructor strings require an extra level of backslash escaping that regex literals do not.
Native engine: tests use your browser's JavaScript RegExp implementation inside a disposable Web Worker with an 800 ms limit. Match indices, lookbehind and other newer capabilities are feature-detected.
Private processing: your pattern, text, replacement and test cases never leave this browser. A permalink contains data only in the URL you choose to copy.
Technical review: reviewed by Starlight Robotics engineering on . Syntax claims follow the MDN JavaScript RegExp reference and the ECMAScript specification.