Text
Regex Tester
Regex Tester is a tool that takes a regular expression and a sample text and instantly shows matched substrings highlighted in place, the contents of every capture group, a replacement preview, and a per-token explanation of the pattern. It is built for everyday needs: designing form validation in a web app, extracting IDs from logs, doing one-off bulk replacements in a document, and learning regex by trial and error.
Pattern explanation
Enter a pattern to see per-token explanations here.
Save the current pattern, flags, test text, and replacement template in the URL to share with a link.
Your pattern and text are processed entirely in your browser and never sent to any server.
Related Tools
Character Counter
Count characters, characters-excluding-whitespace, and line count of any text in real time.
Text Diff Checker
A diff tool that compares two pieces of text and highlights the differences at the line, word, or character level. Supports ignoring whitespace, newlines, and case, and lets you copy the result as a unified diff. Runs entirely in your browser.
JSON Linter
Validates JSON syntax and formats it with your chosen indent.
Password Generator
Generates secure passwords with fine control over length, character sets, and excluded characters.
About Regex Tester
Regex Tester is a tool that takes a regular expression and a sample text and instantly shows matched substrings highlighted in place, the contents of every capture group, a replacement preview, and a per-token explanation of the pattern. It is built for everyday needs: designing form validation in a web app, extracting IDs from logs, doing one-off bulk replacements in a document, and learning regex by trial and error.
You can toggle the g / i / m / s / u / y flags individually. When the pattern is invalid, an inline error tells you exactly what went wrong instead of crashing the page. The number of matches, the number of capture groups, and the execution time in milliseconds are shown alongside the results, so you can sanity-check complex patterns or get a rough feel for performance.
Common patterns — email address, URL, Japanese phone number, postal code, IPv4, date, HTML tag, and hex color code — are one-click presets. In the replacement template you can use $& for the whole match, $1 $2 for numbered captures, and $<name> for named captures; the result switches between the "Match results" and "Replacement" tabs. The "Copy share URL" button packs the current pattern, flags, test text, and replacement template into the URL so you can share the exact view with a teammate.
Everything happens locally in your browser. Your pattern and your test text are never sent to a server, so you can safely try regexes against confidential logs or text that contains personal data. Runs entirely in your browser.
How to use
- Enter a regex into the Pattern field. You can also insert email, URL, and other common patterns from the preset menu with one click.
- Toggle the g / i / m / s / u / y flags on the right to control global matching, case sensitivity, and other behavior.
- Paste the text you want to match into the Test text field. Use the Insert sample button for an instant working example.
- The result area below highlights every match and shows the count, capture groups, and execution time.
- Switch to the Replacement tab and enter a replacement template (which can reference captures with $1 or $&) to see a live replacement preview.
- Open Pattern explanation to see each construct in the pattern broken down into a plain-English description.
- Click Copy share URL to bundle the current pattern, flags, test text, and replacement template into a URL, so anyone can open the same view from one link.
Use cases
- Web engineers prototyping form-validation regexes against the strings users actually submit.
- Operators extracting IDs, paths, and status codes from server or access logs.
- Writers and editors safely previewing bulk replacements across drafts or CSV data before applying them.
- Team leads sharing regex examples and test cases by URL during PR reviews or study sessions.
- Learners stepping through regex constructs one at a time while reading the per-token explanation.
Notes
- This tool uses the standard JavaScript regular expression engine (ECMAScript RegExp). PCRE- or Oniguruma-specific constructs such as \K and variable-length lookbehinds are not supported.
- When the g flag is off, only the first match is found and only the first occurrence is replaced. Turn on the g flag to act on every match.
- Turning on the u flag enables surrogate-pair and Unicode property (\p{...}) support, but tightens escape rules inside character classes. If behavior changes unexpectedly, check the u flag.
- Test text longer than 500,000 characters is cut off before execution to avoid runaway computation. Matches are also capped at 10,000 results.
- The shareable URL includes the test text as a query string. Confirm that it is safe to share before sending the link. Very long inputs are automatically dropped from the URL with a notice.
- Pattern explanation covers the core constructs (character classes, quantifiers, groups, alternation, character sets). Lookahead, lookbehind, and Unicode properties are shown as Unsupported syntax with the raw source.