Free Online Regex Tester
Test and debug regular expressions in real time with our free online regex tester.
Enter a pattern and a test string, and matches highlight instantly —
no button clicks needed. View all capture groups and their positions at a glance.
All processing runs entirely in your browser using JavaScript —
your data never leaves your device.
How to Use
- Enter your regex pattern in the Pattern field (e.g.
\d{3}-\d{4} for phone numbers)
- Type or paste your test string in the left panel
- Toggle flags (g for global, i for case-insensitive, etc.) as needed
- Matches and capture groups appear instantly in the right panel
- Click Copy to copy the regex pattern to your clipboard
Supported Flags
- g (global) — Find all matches rather than stopping after the first
- i (case insensitive) — Match letters regardless of case
- m (multiline) —
^ and $ match start and end of each line
- s (dotAll) — The dot
. matches newline characters too
Common Regex Patterns
- Email:
[\w.-]+@[\w.-]+\.\w{2,}
- Phone (US):
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
- URL:
https?:\/\/[\w.-]+(?:\/[\w./-]*)?
- Date (YYYY-MM-DD):
\d{4}-\d{2}-\d{2}
- IPv4 address:
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
- Hex color:
#(?:[0-9a-fA-F]{3}){1,2}
Regex Syntax Quick Reference
. — Any character except newline
\d — Any digit (0–9)
\w — Any word character (a–z, A–Z, 0–9, _)
\s — Any whitespace
[abc] — Any of a, b, or c
[^abc] — Not a, b, or c
a{3} — Exactly 3 a's
a{2,5} — Between 2 and 5 a's
a* — Zero or more a's
a+ — One or more a's
a? — Zero or one a
(group) — Capture group
(?:group) — Non-capturing group
^ — Start of string (or line with m flag)
$ — End of string (or line with m flag)
Frequently Asked Questions
Is my input data sent to a server?
No. All regex matching is done entirely in your browser with JavaScript. Your test string is never transmitted anywhere. This tool works offline as well.
Why does my regex not match anything?
Check for escaping special characters. In regex, ., *, +, ?, (), [], {}, \, |, ^, $ are all special. Use \. to match a literal dot. Also make sure you have the global (g) flag enabled to find all matches.
What are capture groups?
Capture groups are portions of your match enclosed in parentheses (...). For example, in the pattern (\w+)@(\w+) matched against alice@example: the full match is alice@example, group 1 is alice, and group 2 is example. Groups are displayed with their index and content.
What does the global (g) flag do?
Without g, the regex engine stops after finding the first match. With g, it returns all matches. Most use cases need the global flag enabled.
Can I test regex in different programming languages?
This tool uses JavaScript's RegExp engine. Most common patterns behave the same across languages, but some features (like lookbehind (?<=...)) were added to JavaScript only in ES2018 and may not be supported in older environments or other languages' implementations.