Regex Tester
Test regular expressions with live match highlighting and flags.
Recommended tools
Free CDN, DNS, and edge hosting for developers.
Affordable domains and SSL certificates.
Affiliate links — we may earn a commission if you sign up.
About the Regex Tester
Regex Tester is a live sandbox for experimenting with JavaScript regular expressions. A Regular expression input accepts a bare pattern like the ones a developer passes to a RegExp constructor, and it also understands literal notation, so wrapping a pattern in leading and trailing slashes plus flag characters, such as /pattern/gim, sets the same flags inline. The Flags row offers five checkboxes: g for global matching, i for case-insensitive, m to make anchors aware of line boundaries, s so the dot matches newlines, and u for Unicode. As you type, the tool scans the Test text and paints every match with a yellow highlight in the preview area, while the Match list below itemizes each hit with its character index, matching value, and any capture groups. The stat tiles show Match count, the active Flags, Text chars, and the shared Matched chars. Invalid patterns, such as an unterminated group, stop the scan with a red alert and a toast instead of crashing. Copy matches exports every matched value one per line for pasting into scripts, and Clear text resets the sample document.
Examples
Pattern \b\w+@\w+\.\w+\b, flags g + i, text: Contact us at hello@fernandeslabs.com or sales@fernandeslabs.io for details. No email here: not-an-email Backup: support@fernandeslabs.dev
3 matches: hello@fernandeslabs.com at index 14, sales@fernandeslabs.io at index 41, and support@fernandeslabs.dev at index 113, all highlighted in the preview.
Pattern (\d{3})-(\d{3})-(\d{4}), flags g, text: Call 555-123-4567 or (800) 555-0199 today.First match 555-123-4567 at index 5 with groups [555, 123, 4567]; second match 555-0199 at index 24 with groups [555, 0199].
Pattern (unclosed, flags g, text Sample line here.
No matches — a red alert shows the JavaScript error Unterminated group and a toast repeats Invalid regex: Unterminated group.
How to use
- 1
Type a regular expression into the Regular expression input, or use the /pattern/gi literal form to set flags inline.
- 2
Toggle the g, i, m, s, and u checkboxes to control matching behavior.
- 3
Paste or edit the Test text and watch the highlighted preview mark every match.
- 4
Read the Match list rows for each hit's index, value, and capture groups.
- 5
Use Copy matches to export each matched value on its own line, or Clear text to start over.
Common use cases
- Checking that an email pattern matches real addresses before deploying a form validator.
- Extracting fields with capture groups from log lines or structured text.
- Validating input masks like phone numbers or hex colors against test cases.
- Comparing flag behavior, such as anchors with m enabled, on multi-line content.
- Prototyping a search filter for a web app before writing the handler.
- Teaching regex concepts live, showing index positions and group captures as you type.
Best practices
- Test with the g flag on real documents so the match list reflects all occurrences, not just the first.
- Enable the u flag before matching emoji or accented characters to avoid surprising code-point splits.
- Anchor patterns with word boundaries to prevent unwanted partial matches inside longer words.
- Verify capture groups separately, since a working overall match can still contain a wrong capture.
- Test on representative data, including edge cases like empty strings, when building validators.
- Watch the Matched chars stat to eyeball whether matches cover the intended portion of the document.
Tips
- Use the inline /pattern/flags form to document a pattern exactly as it will appear in source code.
- Toggle the u flag before testing with emoji or accented characters to get predictable matches.
- Enable m when anchors should respect line boundaries, especially when analyzing multi-line logs.
- Craft a pattern with one capture group per field to verify extraction logic in a single pass.
Frequently asked questions
Explore more developer tools
Browse the full collection of developer tools on the hub, or jump back to all categories.