Regex Tester
Regex Tester
Test regular expressions against a string. Matches are highlighted in real time.
About the Regex Tester
Regular expressions are a compact language for describing text patterns: "a word followed by digits", "anything that looks like an email", "a date in YYYY-MM-DD format". They power search-and-replace in editors, input validation, log parsing and data extraction. They are also notoriously easy to get subtly wrong.
This regex tester runs your pattern against a test string as you type and highlights every match. It lists each match with its position and capture groups, and supports the g (global), i (case-insensitive), m (multiline) and s (dot matches newline) flags. It uses your browser's JavaScript regex engine.
Common uses
- Building and debugging validation patterns for forms and APIs.
- Writing patterns to extract IDs, timestamps or error codes from logs.
- Preparing search-and-replace expressions for VS Code, IntelliJ or
sed. - Learning regex syntax by experimenting with real text.
How to use it
- Enter your pattern between the slashes (without the surrounding
/). - Toggle the flags you need.
- Paste sample text into Test String. Matches are highlighted instantly and listed under Match List.
Example
Extracting ISO dates with named capture groups (flag g):
Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Text: Released 2025-11-03, patched 2026-01-15.
Match 1: 2025-11-03 (year=2025, month=11, day=03)
Match 2: 2026-01-15 (year=2026, month=01, day=15)
Tips and common pitfalls
- Escape characters that have special meaning —
. * + ? ( ) [ ] { } ^ $ | \— when you mean them literally.\.matches a dot;.matches any character. - Quantifiers are greedy by default.
<.+>matches from the first<to the last>; use<.+?>for the shortest match. - Use anchors
^and$for validation; without them,\d{3}also matches insideabc12345. - Patterns with nested quantifiers such as
(a+)+can take exponential time on some inputs (ReDoS). Keep patterns specific.
Frequently asked questions
Will my regex work the same in C#, Python or Java?
The core syntax is shared, but there are differences: lookbehind support, named-group syntax ((?<name>) vs (?P<name>) in Python), possessive quantifiers and Unicode classes vary. Test in your target language for edge cases.
What does the g flag do?
Without g, only the first match is found. With it, the engine continues searching and returns all matches.
How do I match across multiple lines?
Use m so ^ and $ match at each line, and s so . also matches newline characters.
Is my test text sent to a server?
No. Matching runs in your browser.