Regex Tester
Test regex patterns against sample input and review highlighted matches in real time.
Regex pattern
Sample text
Live match preview
Alice and Bob built DevToolsHub in Blazor.
Regex matches
Match metadata
What is a regex tester?
A regex tester (regular expression tester) lets you write a pattern and immediately see which parts of your sample text it matches, with visual highlighting and metadata showing the position and length of each match. Testing regex patterns interactively is far faster than running code in a terminal — you can refine a pattern in seconds, see edge cases highlighted in real time, and copy the final expression directly into your codebase.
Essential regex syntax reference
Regular expressions use a compact syntax where each character or construct has a specific meaning:
- . — matches any single character except a newline
- \d — matches a digit (0–9); \D matches any non-digit
- \w — matches a word character (letter, digit, underscore); \W matches non-word
- \s — matches whitespace (space, tab, newline); \S matches non-whitespace
- ^ — anchors the match to the start of a line; $ anchors to the end
- \b — word boundary — the position between a word character and a non-word character
- * — zero or more of the preceding element; + — one or more; ? — zero or one
- {n,m} — between n and m repetitions of the preceding element
- [abc] — character class matching a, b, or c; [^abc] matches anything except a, b, or c
- (group) — capturing group; (?:group) — non-capturing group
- (?=ahead) — positive lookahead; (?<=behind) — positive lookbehind
How to use this tool
- Enter your regex pattern in the top editor.
- Paste your sample text in the lower editor.
- Matches are highlighted automatically as you type.
- Enable "Case insensitive" or "Multiline" flags using the checkboxes if needed.
- Review match count, index, and length in the JSON output panel.
.NET regex — what's different
This tester uses .NET's regex engine, which supports the full set of features found in most modern flavours plus some .NET-specific additions: named groups with (?<name>...), balancing groups for matching nested structures, and atomic groups with (?>...). Unlike JavaScript regex, .NET supports variable-length lookbehinds, which allows patterns like (?<=\d{2,4})- to look back a variable number of characters.
Practical regex patterns for developers
- Email (basic):
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL:
https?://[^\s/$.?#].[^\s]* - IPv4 address:
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b - ISO date:
\d{4}-\d{2}-\d{2} - Hex colour code:
#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b - Whitespace-only lines:
^\s*$(use with multiline flag)
Performance considerations
Certain regex patterns cause catastrophic backtracking — the engine tries an exponential number of combinations before giving up. The most common cause is nested quantifiers such as (a+)+. If your regex is extremely slow on certain inputs, look for adjacent quantifiers and consider rewriting with atomic groups or possessive quantifiers to eliminate ambiguity in how the engine can match a given character.