Regex Tester - Live Matches & Flags | Free Online Tool
What is a regex tester?
A regex tester lets you paste a pattern and sample text, then shows matches and capture groups instantly. Use it to validate patterns before you ship them in code, search, or form validation.
How to use the regex tester
- Enter a pattern: Paste a regex without surrounding slashes (e.g.,
\w+@\w+\.\w+). - Set flags: Start with
g(global). Addifor case-insensitive,mfor multiline,ufor Unicode. - Test text: Paste sample input below; results show live with indices and groups. Copy the clean JSON output if you need to log or share.
Why use this regex tester?
- Instant feedback: See matches and errors as you type.
- Capture awareness: View indices and named groups to confirm structure.
- Privacy-first: All parsing runs in your browser; no text is uploaded.
Use case 1: Validate an email-ish pattern
Pattern: ^[\\w.-]+@[\\w.-]+\\.[A-Za-z]{2,}$
Paste a few addresses and confirm only valid ones match.
Use case 2: Extract IDs from URLs
Pattern: /posts/(?<id>\\d+)
Paste several URLs; check that id is captured correctly.
Use case 3: Clean up logs
Pattern: ERROR\\s+(?<code>\\d{3})
Paste log lines and verify the code group.
Examples
Basic example
Pattern: cat
Text: concatenate catalog cat
Output shows all cat matches with their indices.
Advanced example
Pattern: (?<user>[A-Za-z0-9_]+)@(example|textavia)\\.com
Flags: gi
Text: multiple email addresses → output lists matches and named group user.
Common errors
Invalid flag or pattern
If the regex fails to compile, you’ll see Invalid regex: with the JS engine’s message. Fix the pattern or remove unsupported flags.
Empty matches in global mode
Zero-length matches can loop; this tool advances the index automatically. If you see unexpected repeats, adjust the pattern to avoid empty matches.
Tips and proven approaches
- Start simple, then add anchors (
^,$) and groups. - Use non-greedy quantifiers
*?+?when you want the smallest match. - Prefer named groups (
(?<name>...)) for clarity; check them in the JSON output. - Turn on
mfor multiline anchors anduwhen working with emoji or accented text.
Related tools
- Format JSON output with the JSON formatter.
- Minify patterns inside code with the JSON minifier if needed.
- Compare two patterns’ outputs with the diff tool.
Privacy and security
All regex evaluation happens locally in your browser using JavaScript’s RegExp engine. Your text and patterns are not uploaded or stored.