Regex Tester
Debug and test regular expressions in real-time.
About Regex Tester
Regular Expressions (Regex) are powerful sequences of characters that define search patterns. They are used for string matching, search-and-replace, and data validation across almost every programming language.
Common Token Reference
- \d: Matches any digit (0-9).
- \w: Matches any word character (alphanumeric + underscore).
- \s: Matches any whitespace character (space, tab, newline).
- ^: Matches the beginning of the string, or of each line with the m flag.
- $: Matches the end of the string, or of each line with the m flag.
Flags in This Tester
- g (global): finds every match. Without it, only the first match is highlighted.
- i (ignore case): treats uppercase and lowercase letters as the same.
- m (multiline): lets
^and$match at every line break, not only at the start and end of the whole text.
All three flags are on by default. JavaScript also has s, u, v, y and d, which this tester does not expose. The Matches panel highlights each full match and shows the total, but it does not list capture groups separately. The Explanation tab breaks your pattern into escapes, groups, character sets, quantifiers, anchors and literals.
JavaScript Regex vs Other Flavors
Most patterns written for PCRE (PHP), Python or Java work unchanged, but not all. JavaScript has no possessive quantifiers such as a++ and no atomic groups. Named groups use (?<name>...), so Python's (?P<name>...) form is rejected, and \d matches only the ASCII digits 0-9.
Avoid Catastrophic Backtracking
Nested quantifiers such as (a+)+$ can take exponential time on input that almost matches, a weakness known as ReDoS. The pattern runs directly in your browser tab, so a runaway pattern can freeze the page; if that happens, reload and simplify it. Before using a regex on user input, prefer specific character classes to .*, anchor the pattern, and test it against long strings that don't match.