All processing happens locally in your browser — nothing is sent to any server
Enter a regex pattern to get started
Regex Tester is a free online tool for testing regular expressions with real-time match highlighting, capture group inspection, and replacement preview. Includes a built-in pattern library and token-level explanation. Runs entirely in your browser.
What is a Regex Tester?
A regex (regular expression) tester is an interactive tool that lets you build and test regex patterns against sample text in real time. Use it alongside JSON formatter for data validation or Text Case Converter for batch text transformations.
As you type, matches are highlighted directly in the test text, and a detailed match list shows each match with its position, captured groups, and length.
This tool runs entirely in your browser — no data is ever sent to any server.
Key Features
- Real-time match highlighting — see matches visually in your test text with alternating colors for clarity.
- Capture group inspection — view named and numbered capture groups for each match.
- Replacement preview — test regex-based find-and-replace with support for $1, $&, and '$<name>' replacement tokens.
- Pattern explanation — token-level breakdown of your regex, showing what each part means (e.g., \d+ → "one or more digits").
- Catastrophic backtracking protection — matching runs in a background thread with a timeout, so bad patterns won't freeze the page.
- Preset library — quick-start with common patterns for email, URL, IP, phone, passwords, and more.
Common Use Cases
- Learning regex — see how each token contributes to matching, and test your understanding against sample text.
- Debugging — paste an existing regex and test it against actual data to verify it matches what you expect.
- Data extraction — use capture groups to extract specific parts from log files, CSVs, or structured text.
- Find and replace — preview complex text transformations before applying them in your code.
- Validation — test email, phone, URL, and other validation patterns against edge cases.
Cheatsheet
| Token | Meaning | Example |
|---|---|---|
| Character Classes | ||
| \d | Any digit (0-9) | 123 → matches 1,2,3 |
| \w | Any word character (a-z, A-Z, 0-9, _) | a1_ → matches a,1,_ |
| \s | Any whitespace (space, tab, newline) | "a b" → space match |
| [...] | Custom character class | [aeiou] → vowels |
| [^...] | Negated character class | [^0-9] → non-digits |
| Anchors & Boundaries | ||
| ^ | Start of string | "^hello" → at start |
| $ | End of string | "end$" → at end |
| \b | Word boundary | "\bword\b" → word |
| \B | Non-word boundary | "\Bing\B" → inside |
| Quantifiers | ||
| * | Zero or more | a* → "", a, aa, aaa |
| + | One or more | a+ → a, aa, aaa |
| ? | Zero or one | a? → "", a |
| {n} | Exactly n | a{3} → aaa |
| {n,} | At least n | a{2,} → aa, aaa |
| {n,m} | Between n and m | a{2,4} → aa, aaa, aaaa |
| *?, +?, ?? | Lazy variant (match as few as possible) | "<.*?>" → shortest match |
| Groups & Lookaround | ||
| (...) | Capturing group | (abc)+ → capture abc |
| (?:...) | Non-capturing group | (?:abc)+ → group w/o capture |
| (?<name>...) | Named capturing group | "(?<year>\d{4})" |
| (?=...) | Positive lookahead | q(?=u) → q followed by u |
| (?!...) | Negative lookahead | q(?!u) → q not followed by u |
| (?<=...) | Positive lookbehind | "(?<=@)\w+" |
| (?<!...) | Negative lookbehind | "(?<!@)\w+" |
| Escapes | ||
| \n | Newline | "line\n" → newline |
| \t | Tab | "col\t" → tab |
| \\ | Literal backslash | "c:\\path" |
| \. | Literal dot | "end\." → literal dot |
| \/ | Literal forward slash | "path\/to\/file" |
Limitations
- JavaScript regex only — this tool uses the browser's built-in regex engine. PCRE, Python, and other regex flavors may behave differently.
- No lookbehind in older browsers — lookbehind assertions (?<=...) require ES2018+.
- Match cap at 1,000 — to keep the UI responsive, only the first 1,000 matches are rendered.
- Capturing groups not highlighted in text — groups are shown in the match list, not inline in the highlighted text.