Regex Tester
Write a pattern, pick flags and test against any string. Matches highlight live with index, length and capture groups for quick debugging.
Test string
Highlighted matches
What is a regex tester?
What this tool does
A regex tester lets you write a regular expression, set flags, and run it against sample text with instant visual feedback. This tool highlights every match in the test string, lists each hit with index and length, and shows numbered capture groups. Built-in presets for email, URL, UUID, hex color, IPv4, ISO date, slug, and HTML tag patterns give you a starting point you can customize. The sticky sidebar keeps pattern controls visible while you scroll long test strings.
Why you need it
Regular expressions are powerful but easy to get wrong—a missing anchor, wrong flag, or greedy quantifier silently matches too much or nothing at all. Testing in production logs or live code is slow and risky. A live tester shows exactly what matches before you commit a pattern to validation logic, search-and-replace scripts, or grep commands. Because matching runs in your browser, proprietary log excerpts and customer data stay on your machine. Whether you are validating form input, parsing log lines, or extracting IDs from URLs, seeing matches highlighted beats guessing from a single boolean result. Presets accelerate common patterns so you spend less time looking up character-class syntax.
How to use it
- Paste or type your test string in the top panel.
- Enter a pattern manually or pick a preset from the dropdown to load a starter regex.
- Toggle flags: global (g) for all matches, ignore case (i), multiline (m), dot-all (s), and unicode (u).
- Review highlighted matches, the match count, and capture group values in the sidebar list.
- Load the sample to explore preset patterns, then clear before pasting sensitive log data.
Practical examples
- Verify an email or URL validation regex before adding it to a form handler.
- Debug why a log grep returns zero hits by testing anchors and escaping on a sample line.
- Extract capture groups from an ISO date or UUID pattern to see which sub-match maps to which field.
- Prototype a pattern here, then port it to the Find & Replace tool for bulk text rewrites.
- Validate an IPv4 or hex-color preset against edge-case strings before shipping client-side validation.
How it works
Regular expressions describe text patterns using literals, character classes, quantifiers, anchors, and grouping. This tool uses JavaScript RegExp semantics—the same engine modern browsers and Node.js use—so patterns behave like they will in front-end code. The global flag finds all non-overlapping matches; without it, only the first match returns. Capture groups in parentheses populate numbered slots you see in the match list. The highlight panel wraps each match so you can spot partial hits inside long strings. Matching executes entirely client-side on each keystroke. Very complex patterns on huge strings can cause catastrophic backtracking and freeze the tab, so test on representative samples first. Invalid patterns show an error in the status bar instead of failing silently.
Common mistakes
- Forgetting to escape dots (match any character) when you mean a literal period in URLs or file extensions.
- Missing the global flag and assuming the pattern fails when only the first match is shown.
- Expecting PCRE or Python regex behavior—lookbehind and Unicode property escapes differ by engine.
- Running nested quantifiers like
(a+)+on megabyte strings, which can hang the browser. - Using overly strict email or URL regex for production validation—real-world addresses exceed simple patterns.
FAQ
Which regex flavor is used?
JavaScript RegExp semantics as in modern browsers — backreferences and lookahead supported per ES spec.
Why does my pattern not match?
Check flags, escaping (dots vs \.), and anchoring (^ $). The match list shows zero hits explicitly.
Can I test replace operations?
This tool focuses on matching and groups. Use your IDE or code for replace previews.
Are catastrophic backtracking patterns safe?
Complex patterns on huge strings may freeze the tab. Test on samples first.
Is my test data uploaded?
No. Matching runs entirely client-side.