Regex Tester Tool: Test and Debug Regular Expressions Online
How to use a regex tester tool to write, test, and debug regular expressions. Includes a guide to regex syntax, common patterns, and tips for avoiding common mistakes.
Regex Tester Tool: Test and Debug Regular Expressions Online
Regular expressions are powerful but unforgiving. A misplaced . or missing escape changes everything. A good regex tester tool lets you see matches in real time, understand what your pattern is doing, and catch mistakes before they reach production.
Best Free Regex Tester Tool
DevPlaybook Regex Tester β test your regex against multiple strings simultaneously, see matches highlighted, and inspect capture groups.
Key features:
- Live match highlighting as you type
- Capture group visualization
- Flag toggles (global, case-insensitive, multiline, dotAll)
- Reference panel with common patterns
- No account required
How to Test Regex Online
- Enter your pattern (without
/delimiters) - Set flags as needed (g for all matches, i for case-insensitive)
- Paste your test strings
- See matches highlighted in real time
Example: Testing an email pattern
Pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Flags: i (case-insensitive)
Test strings:
[email protected] β match
not-an-email β no match
[email protected] β match
@nodomain.com β no match
Regex Syntax Quick Reference
Character Classes
| Pattern | Matches |
|---|---|
. | Any character except newline |
\d | Digit (0-9) |
\D | Non-digit |
\w | Word character (a-z, A-Z, 0-9, _) |
\W | Non-word character |
\s | Whitespace (space, tab, newline) |
\S | Non-whitespace |
[abc] | Any of: a, b, c |
[^abc] | Not any of: a, b, c |
[a-z] | Range: a through z |
Quantifiers
| Pattern | Meaning |
|---|---|
* | 0 or more |
+ | 1 or more |
? | 0 or 1 (optional) |
{n} | Exactly n times |
{n,} | n or more times |
{n,m} | Between n and m times |
*? | 0 or more (non-greedy) |
+? | 1 or more (non-greedy) |
Anchors
| Pattern | Meaning |
|---|---|
^ | Start of string (or line with m flag) |
$ | End of string (or line with m flag) |
\b | Word boundary |
\B | Not a word boundary |
Groups
| Pattern | Meaning |
|---|---|
(abc) | Capturing group |
(?:abc) | Non-capturing group |
(?<name>abc) | Named capturing group |
(?=abc) | Positive lookahead |
(?!abc) | Negative lookahead |
(?<=abc) | Positive lookbehind |
(?<!abc) | Negative lookbehind |
Common Regex Patterns for Developers
Email Validation
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Note: This is a reasonable practical check, not RFC 5322 compliant. The full spec is extraordinarily complex.
URL
https?://[^\s/$.?#].[^\s]*
Or more precisely:
^(https?|ftp)://[^\s/$.?#].[^\s]*$
IP Address (IPv4)
^(\d{1,3}\.){3}\d{1,3}$
Strict version (validates 0-255 range):
^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$
Phone Number (US)
^(\+1\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$
Date (YYYY-MM-DD)
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
UUID
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
Case-insensitive version:
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
Credit Card (basic format check)
^4[0-9]{12}(?:[0-9]{3})?$ # Visa
^5[1-5][0-9]{14}$ # Mastercard
^3[47][0-9]{13}$ # Amex
HTML Tag Stripping
<[^>]*>
Replace matches with empty string to remove tags. (For real HTML parsing, use a proper parser β regex has well-known limitations with nested structures.)
Hex Color
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
Semantic Version
^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
Regex Flags Explained
Flags modify how the pattern matches:
| Flag | Code | Effect |
|---|---|---|
| Global | g | Find all matches (not just first) |
| Case insensitive | i | [a-z] matches upper and lower case |
| Multiline | m | ^ and $ match line boundaries, not just string boundaries |
| Dot all | s | . matches newlines too |
| Unicode | u | Enable Unicode support, proper emoji/Unicode matching |
// JavaScript
const re = /pattern/gi; // global, case-insensitive
// Using RegExp constructor
const re2 = new RegExp('pattern', 'gi');
Common Regex Mistakes
1. Not Escaping Special Characters
These characters have special meaning in regex: . * + ? ^ $ { } [ ] | ( ) \
To match them literally, escape with \:
Pattern to match "1.5": 1\.5 (not 1.5, which matches "1X5" too)
Pattern to match "(": \(
Pattern to match "$": \$
2. Greedy vs Non-Greedy
Greedy quantifiers match as much as possible:
Pattern: <.+>
String: <a>hello</a>
Match: <a>hello</a> (greedy: takes the whole thing)
Non-greedy (? after quantifier) matches as little as possible:
Pattern: <.+?>
String: <a>hello</a>
Matches: <a> and </a> (non-greedy: stops at first >)
3. ^ Inside Character Classes
^ at the start of a character class negates it:
[abc] matches a, b, or c
[^abc] matches anything EXCEPT a, b, or c
Outside character classes, ^ anchors to start of string.
4. . Doesnβt Match Newlines by Default
// Doesn't match across newlines
/start.+end/.test('start\nend') // false
// Use dotAll flag to match newlines
/start.+end/s.test('start\nend') // true
// Or use [\s\S] to match everything including newlines
/start[\s\S]+end/.test('start\nend') // true
5. Catastrophic Backtracking
Some patterns can cause exponential slowdown on certain inputs:
Dangerous pattern: (a+)+
Input: "aaaaaaaaaaaaaaaaab"
Result: engine tries exponentially many combinations before giving up
Avoid nested quantifiers on overlapping character classes.
Regex in Different Languages
The core syntax is consistent, but details vary:
JavaScript:
const match = 'hello'.match(/h(e)llo/);
const replaced = 'hello world'.replace(/world/, 'there');
const found = /^\d+$/.test('123');
Python:
import re
match = re.search(r'h(e)llo', 'hello')
replaced = re.sub(r'world', 'there', 'hello world')
found = bool(re.match(r'^\d+$', '123'))
Go:
import "regexp"
re := regexp.MustCompile(`h(e)llo`)
match := re.FindString("hello")
When Not to Use Regex
Regex is not always the right tool:
- Parsing HTML/XML β use a proper DOM parser (BeautifulSoup, cheerio, etc.)
- Validating emails βproperlyβ β the full RFC spec is not practical to regex
- Parsing deeply nested structures β use a parser generator or library
- Lexing/parsing programming languages β regex can handle tokens but not grammar
Regex is best for: search, simple validation, transformation of well-defined string formats.
Practice
The best way to learn regex is to test real patterns against real data. Use DevPlaybook Regex Tester to experiment β it shows live matches, capture groups, and has a quick-reference panel built in.
Start with simple patterns, add complexity one piece at a time, and always test against edge cases (empty strings, Unicode characters, very long inputs).
Free Newsletter
Level Up Your Dev Workflow
Get new tools, guides, and productivity tips delivered to your inbox.
Plus: grab the free Developer Productivity Checklist when you subscribe.
Found this guide useful? Check out our free developer tools.
Affiliate disclosure: Some links below are affiliate links β we may earn a small commission at no extra cost to you. Learn more.
Recommended Tools & Resources
DigitalOcean
$200 credit for new users. Simple, affordable cloud hosting for developers.
GitHub Student Pack
Free access to 100+ developer tools. Perfect for students and new devs.
Vercel
Deploy frontend apps instantly. Free tier is generous for side projects.
DevPlaybook Products
Boilerplates, scripts & AI toolkits to 10x your dev workflow.