Regex Tester
Test regular expressions with real-time match highlighting.
About Regex Tester
A regular expression — regex for short — is a compact pattern language for matching, extracting, and replacing text. Originally formalised in the 1950s by mathematician Stephen Kleene, regex is now built into virtually every programming language and editor. This tester runs your pattern against the JavaScript RegExp engine, the same engine used by Node.js, browsers, and the Bun runtime.
The tool re-evaluates the pattern on every keystroke, highlighting matches in the test string and listing every match with its index and capture groups in a table. Common flags are toggleable: g (global) returns all matches, i (case-insensitive) ignores letter case, m (multiline) makes ^ and $ match line boundaries, s (dotAll) makes . match newlines, and u (unicode) enables full Unicode property support.
Use cases
- Validate email, phone, or ID formats before shipping a form validator.
- Extract URLs, dates, or numbers from a block of log text.
- Debug a pattern that is not matching as you expect by seeing matches highlighted live.
- Prototype a replacement rule before dropping it into your code editor.
- Test backreferences, lookaheads, and named capture groups before committing them.
Best practices
- Anchor patterns with ^ and $ when validating an entire string to avoid partial matches.
- Prefer non-greedy quantifiers (.*?) when matching content between delimiters.
- Use named capture groups (?<name>...) for readable code and self-documenting patterns.
- Escape literal special characters: . * + ? ^ $ { } ( ) | [ ] \ all need a backslash.
Reference
| Token | Meaning |
|---|---|
| . | Any single character (except newline unless s flag) |
| \d / \D | Digit / non-digit |
| \w / \W | Word character (letter, digit, underscore) / non-word |
| \s / \S | Whitespace / non-whitespace |
| ^ / $ | Start / end of string (or line with m flag) |
| \b / \B | Word boundary / non-boundary |
| * | Zero or more (greedy) |
| + | One or more (greedy) |
| ? | Zero or one, or non-greedy modifier when after a quantifier |
| {n,m} | Between n and m repetitions |
| (...) | Capture group |
| (?:...) | Non-capturing group |
| (?<name>...) | Named capture group |
| (?=...) / (?!...) | Positive / negative lookahead |
| (?<=...) / (?<!...) | Positive / negative lookbehind |