Regex Tester
Test and debug regular expressions with real-time matching. See all matches, capture groups, and index positions instantly in your browser.
Regular Expression
Test String
How to Use the Regex Tester
Enter a regular expression pattern in the pattern field, toggle the flags you need, then paste your test string in the text area. Matches are highlighted in real time — each match shows its index position and any capture groups.
What is a Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used for string searching, validation, and text manipulation in virtually every programming language. Regex patterns can match literal text, character classes, repetitions, anchors, and more.
Common Regex Patterns
- Email —
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL —
https?://[^\s/$.?#].[^\s]* - IPv4 address —
(\d{1,3}\.){3}\d{1,3} - Date (YYYY-MM-DD) —
\d{4}-\d{2}-\d{2} - Hex color —
#([a-fA-F0-9]{6}|[a-fA-F0-9]{3}) - Digits only —
^\d+$ - Whitespace (any) —
\s+ - Word boundary —
\bword\b
Regex Cheat Sheet
Anchors
^— Start of string (or line in multiline mode)$— End of string (or line in multiline mode)\b— Word boundary\B— Not a word boundary
Quantifiers
*— 0 or more+— 1 or more?— 0 or 1 (also makes quantifiers lazy){n}— Exactly n times{n,m}— Between n and m times
Character Classes
\d— Digit (0-9)\w— Word character (a-z, A-Z, 0-9, _)\s— Whitespace (space, tab, newline)[abc]— Any of a, b, or c[^abc]— Any character except a, b, or c
Groups
(abc)— Capture group(?:abc)— Non-capturing group(?<name>abc)— Named capture group(?=abc)— Positive lookahead(?!abc)— Negative lookahead
Regex Flags
- g (global) — Find all matches instead of stopping after the first one.
- i (case insensitive) — Match letters regardless of case.
- m (multiline) — Make
^and$match the start and end of each line instead of the whole string. - s (dot all) — Make
.match newline characters as well.
Debugging Tips
- Start simple — Build your pattern incrementally. Match a literal string first, then add character classes and quantifiers.
- Use non-greedy quantifiers — Replace
.*with.*?to avoid over-matching. - Escape special characters — Characters like
. * + ? ( ) [ ] { } ^ $ | \must be escaped with\to match literally. - Check your flags — Forgetting the
gflag is the most common reason only the first match is returned.
Related Guides
- Regex Cheat Sheet for Developers — syntax reference with code examples in JS and Python
- Common Regex Patterns: 20+ Examples — production-ready patterns for emails, URLs, dates, and more
- Regex for Email Validation — patterns that actually work in production
FAQ
Is my data safe?
Yes. All regex testing happens entirely in your browser using JavaScript. No data is sent to any server.
Which flags are supported?
The tool supports g (global), i (case insensitive), m (multiline), and s (dot all) flags. You can combine multiple flags.
Why does my regex match unexpectedly?
Common pitfalls include forgetting to escape special characters like . * + ? ( ) [ ] { } ^ $ | \, or not using the global flag when you expect multiple matches.
What is a capture group?
A capture group is a part of the pattern wrapped in parentheses (). It lets you extract specific parts of a match. For example, (\d+)-(\d+) applied to 2024-01 captures 2024 and 01 as separate groups.
How do I match a literal dot?
Use \. instead of .. In regex, an unescaped dot matches any character. To match a literal period — for example in a file extension or IP address — you must escape it: \.txt or \d+\.\d+\.\d+\.\d+.
Related Articles
Regex for Email Validation: Patterns That Actually Work
Learn 3 email validation regex patterns from simple to RFC-aware. Test each pattern with edge cases in JavaScript, Python, and Go.
Common Regex Patterns: 20+ Examples for Everyday Development
Master 20+ practical regex patterns for validation, data extraction, and text processing. Copy-paste examples in JavaScript and Python with explanations.
Regex Cheat Sheet for Developers
A practical regular expression cheat sheet with common patterns, syntax reference, and real-world examples for JavaScript, Python, and more.