Regex Tester
Test regular expressions in real time with match highlighting and capture group display. Free online regex debugger, runs 100% in your browser.
Quick regex reference
| Pattern | Description |
|---|---|
. | Any character (except newline) |
^ | Start of string / line |
$ | End of string / line |
* | 0 or more repetitions |
+ | 1 or more repetitions |
? | 0 or 1 (optional) |
{n} | Exactly n repetitions |
{n,m} | Between n and m repetitions |
\d | Digit [0-9] |
\D | Non-digit |
\w | Word character [a-zA-Z0-9_] |
\W | Non-word character |
\s | Whitespace |
\S | Non-whitespace |
\b | Word boundary |
[abc] | Class: a, b, or c |
[^abc] | Negation: not a, b, or c |
(abc) | Capturing group |
(?:abc) | Non-capturing group |
(?<n>abc) | Named group "n" |
a|b | Alternative: a or b |
Reference
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Regex is used across virtually every programming language and tool — from form validation in JavaScript to log parsing in Python to search-and-replace in text editors. A pattern combines literal characters, metacharacters (. ^ $ * + ? { } [ ] | ( )), and character classes (\d digit, \w word char, \s whitespace). This tool uses the ECMAScript regex engine (the same one used in JavaScript, TypeScript, and Node.js).
Regex flags explained
g — global: find all matches, not just the first. Essential for counting occurrences or replacing every instance.
i — ignore case: match uppercase and lowercase letters interchangeably. /hello/i matches "Hello", "HELLO", and "hello".
m — multiline: ^ and $ match the start and end of each line, not just the whole string. Critical for line-by-line log parsing.
s — dotAll: the . metacharacter matches newline characters too. Without this flag, . stops at line breaks.
Capturing groups
Capturing groups (pattern) capture the matched substring for extraction or backreference. Named groups (?<name>pattern) assign a readable name to the capture, accessible via match.groups.name — much clearer than numbered groups in complex patterns. Non-capturing groups (?:pattern) group without capturing — useful for applying quantifiers to a sequence without creating an unnecessary capture. Backreferences like $1, $2 in replacement strings refer to the captured text by group number.
Privacy
All matching runs 100% in your browser. No data is sent to a server.