What is a regex tester?
A regex tester lets you develop regular expressions interactively: you type a pattern, provide sample text, and instantly see what matches, where it matches, and what each capture group extracted. Regular expressions are a compact language for describing text patterns - “an email address”, “a date in ISO format”, “any line starting with ERROR” - and they are built into every major programming language, editor, and command-line toolkit.
The catch is that regex syntax is dense and unforgiving; a single misplaced character silently changes what a pattern matches. Writing a regex blind and testing it in production code is slow and error-prone. This tool shortens the loop to milliseconds: matches are highlighted in the test string as you type, a table below lists every match with its position and capture groups, and preset buttons load battle-tested patterns for emails, URLs, IP addresses, ISO dates, and UUIDs. It uses JavaScript's native RegExp engine and runs entirely in your browser, so your test data stays private.
How to use the regex tester
- Enter a pattern in the Pattern field - without the surrounding slashes. For example:
\d{4}-\d{2}-\d{2}to find ISO dates. Or click a preset chip to start from a common pattern with matching sample text. - Set the flags. Leave
g(global) on to find every match; addifor case-insensitive matching,mso^/$work per line, orsso.also matches newlines. - Paste your test string - real data works best: an actual log excerpt, CSV row, or API response fragment.
- Read the highlights. Every match is highlighted in the output panel in real time. No highlights means no matches; a red banner means the pattern itself has a syntax error.
- Inspect the match table. Each row shows the matched text, its character index, and the value of every numbered and named capture group - exactly what your code would receive.
Examples
Extract dates and reformat them
Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Text: Deployed 2026-07-09, rollback point 2026-06-28.
Matches: 2026-07-09 (year: 2026, month: 07, day: 09)
2026-06-28 (year: 2026, month: 06, day: 28)Named groups like (?<year>...) make replacement code self-documenting: in JavaScript you could reformat with str.replace(re, "$<day>/$<month>/$<year>").
Find emails in messy text
Pattern: [\w.+-]+@[\w-]+\.[\w.]+
Text: Contact sales@example.com or support+tickets@help.example.org
Matches: sales@example.com, support+tickets@help.example.orgNote this is a pragmatic pattern, not a full RFC 5322 validator - which is fine, because for real validation you should send a confirmation email anyway.
Match log lines by severity
Pattern: ^ERROR .+$ (with the m flag)
Text: INFO service started
ERROR connection refused to db:5432
WARN retrying in 5s
Matches: ERROR connection refused to db:5432Regex syntax quick reference
.any character ·\ddigit ·\wword character ·\swhitespace*zero or more ·+one or more ·?optional ·{2,5}between 2 and 5 times[abc]any of a, b, c ·[^abc]anything except a, b, c ·a|ba or b^start of string/line ·$end of string/line ·\bword boundary(...)capture group ·(?:...)non-capturing group ·(?<name>...)named group(?=...)lookahead ·(?<=...)lookbehind - assert context without consuming it
Tips for writing better regex
- Build incrementally. Start with a literal fragment that matches, then generalize one piece at a time, watching the highlights after each change.
- Prefer specific classes over dot-star.
"[^"]*"(quote, non-quotes, quote) is faster and more correct than".*?". - Anchor when validating. To check that an entire string matches - not just part of it - wrap the pattern in
^...$. Validating UUIDs, for example, needs anchors; generate test values with the UUID Generator. - Beware catastrophic backtracking. Nested quantifiers like
(a+)+can take exponential time on non-matching input. Keep quantified groups from overlapping. - Know when not to use regex. Structured formats deserve real parsers - check JSON with the JSON Validator and inspect it with the JSON Formatter rather than pattern-matching against raw JSON text.