What is Regex Tester?
Regex Tester lets you write a regular expression, paste test text, and see matches highlighted in real time — along with captured groups and match positions. Build and debug patterns instantly without switching to a code editor.
Regex is one of the most powerful text-processing tools in any developer’s toolkit — and one of the most error-prone to write from memory. Always test patterns against real input before shipping.
Core Regex Syntax Reference
Character Classes
\d (digit), \w (word char), \s (whitespace), [a-z] (range), [^abc] (not these chars).
Quantifiers
* (0+), + (1+), ? (0 or 1), {3} (exactly 3), {2,5} (2 to 5 times). Append ? for lazy matching.
Anchors
^ matches start of string/line, $ matches end. \b matches a word boundary.
Groups
(abc) captures, (?:abc) non-capturing, (?<name>abc) named capture, (a|b) alternation.
Lookahead/behind
(?=...) positive lookahead, (?!...) negative, (?<=...) lookbehind — match without including in result.
How to Use Regex Tester
Enter your pattern
Type your regex in the pattern field (without surrounding slashes).
Set flags
Toggle g (global), i (ignore case), m (multiline), s (dotAll) as needed.
Paste test text
Enter or paste the text you want to test the pattern against.
See highlighted matches
Matches are highlighted in the text. Capture groups are shown in a table below.
Common Regex Patterns
| Pattern | Matches |
|---|---|
\b\d{4}\b | Exactly 4-digit numbers |
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} | Email addresses |
https?://[^\s]+ | HTTP/HTTPS URLs |
#[0-9a-fA-F]{3,6} | Hex color codes |
^\s+|\s+$ | Leading/trailing whitespace (use trim instead) |
\b(TODO|FIXME|HACK)\b | Code annotation markers |
Tips & Common Mistakes
Use non-capturing groups (?:…) by default. If you don’t need to extract a group’s value in code, make it non-capturing to avoid confusion and minor performance cost.
Escape special characters in literals. . matches any character in regex. To match a literal dot, write \.. Same for +, *, (, [, {, ^, $, ?, |, \.
Greedy vs lazy quantifiers matter. .* is greedy — it matches as much as possible. .*? is lazy — it matches as little as possible. For HTML-like patterns, lazy is almost always what you want.
Related Tools
- Find and Replace — apply regex substitutions to text
- Text Diff Checker — compare original vs regex-processed text
- JSON Validator — validate structured data that regex can help extract