Test JavaScript regular expressions live against your own text. See matches highlighted instantly, with index positions and capture groups for every match.
| # | Index | Matched Text | Capture Groups |
|---|
Enter a pattern and test string to see matches
This regex tester lets you try out JavaScript regular expressions against your own text and see the results instantly — no compiling, no copy-pasting into a console, no external service. Type a pattern, set flags, paste in a test string, and every match is highlighted directly in the text, with a detailed table listing each match's position and any capture groups it contains. It's built for the exact regex flavor used by JavaScript engines (the same one powering every web browser and Node.js), which is the flavor most web developers need when validating form input, parsing log lines, or writing a find-and-replace.
As you type, the tester constructs a native RegExp object from your pattern and flags, wrapped in a try/catch so an invalid or incomplete pattern shows a clear error message instead of breaking the page. When the flags include g (global), it uses String.prototype.matchAll() to collect every match in the string, including each match's start index and any capture groups; without g, JavaScript's regex engine only returns the first match, matching real runtime behavior. The highlighted view is built by walking through the test string and the match positions together, inserting each matched span into the display — using safe DOM text nodes rather than raw HTML insertion, so special characters in your test string are always shown as literal text and can never be interpreted as markup.
Regular expressions are notoriously easy to get subtly wrong — an unescaped special character, a missing anchor, or a greedy quantifier that matches far more than intended. Testing a pattern against realistic sample text before dropping it into production code (form validation, log parsing, data extraction) catches these mistakes early, when they're cheap to fix, rather than after they've silently rejected valid input or let bad input through.
g flag to find every match in the string — without it, JavaScript's engine stops after the first match, which is easy to forget when a pattern "isn't matching" the rest of your text.(...) — to pull out specific pieces of each match rather than just confirming a match occurred; the match details table shows every capture group's value.. or * that you intend to match literally (remember to escape them with a backslash).u flag to work correctly.m (multiline) flag, double-check whether you actually want ^/$ to match at every line break, or just at the start/end of the whole string.Finds all matches in the string instead of stopping after the first. Required for matchAll() and for iterating matches with exec() in a loop.
i ignores letter case. m makes ^/$ match at every line break. s (dotAll) lets . match newline characters too.
u enables full Unicode-aware pattern parsing (needed for some escapes and code point ranges). y (sticky) anchors matching to exactly the current search position.
Common questions about regex testing
Explore other developer & tech tools