UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

Regex Tester

Test regular expressions with live matches

About Regex Tester

Regex Tester is a real-time regular expression workbench that highlights all matches inside your test string as you type, with no page reload needed. Enter a pattern, choose flags (g, i, m, s, u), and the tool immediately marks every match in the test string. A match list shows each result with its index and capture groups; invalid patterns display a clear syntax error instead of silently failing. The full JavaScript RegExp feature set is supported: named capture groups, lookaheads, lookbehinds, non-greedy quantifiers, and Unicode property escapes. Developers use it to build input-validation patterns, craft log-parsing expressions, write slug normalisation routines, or reverse-engineer an existing regex to understand what it matches before modifying it.

Why use Regex Tester

Real-Time Match Highlighting

Every match is highlighted inside the test string on each keystroke, with no delay and no button press. This tight feedback loop lets you see immediately whether your pattern is too broad, too narrow, or capturing the wrong group — a significant speed-up over test-run-edit cycles in a code editor.

Named Capture Group Extraction

Match results list every named and numbered capture group individually, showing the group name, matched substring, and position. This makes it fast to verify that a complex pattern with multiple groups is extracting exactly the fields you intend from each match.

Instant Syntax Error Feedback

Invalid regex syntax shows a clear, readable error message from the JavaScript engine the moment you stop typing, rather than crashing silently or producing no matches. This prevents the common debugging trap of thinking a valid pattern simply has no matches when in fact the pattern itself is broken.

Full JavaScript RegExp Feature Set

The tester uses the browser's native RegExp engine, so it supports the complete modern JavaScript syntax: named captures (?<name>...), lookahead and lookbehind assertions, Unicode property escapes (\p{L}), non-greedy quantifiers, and the s (dotAll) and u flags introduced in ES2018.

Multiline Test Strings

Paste an entire log file excerpt, a block of addresses, or multi-paragraph text into the test area. With the m flag enabled, ^ and $ match at the start and end of each line, and the match counter and list update to reflect all occurrences across every line.

Copyable JavaScript Literal Output

The final pattern is rendered in /pattern/flags JavaScript literal syntax, ready to paste directly into source code or a test file without manually adding delimiters or escaping forward slashes inside the pattern.

How to use Regex Tester

  1. Type your regular expression pattern into the pattern field — do not include leading or trailing slashes.
  2. Check or uncheck the flag checkboxes (g for global, i for case-insensitive, m for multiline, s for dotAll, u for Unicode) to match your intended use.
  3. Type or paste your test string into the test area; matches are highlighted in real time as you edit either field.
  4. Review the match list below the test area — each entry shows the matched text, its start index, and any named or numbered capture groups.
  5. If your pattern has a syntax error, an error banner appears with the browser's parser message; fix the pattern and the error clears automatically.
  6. Copy the final regex pattern in JavaScript literal format (/pattern/flags) from the output field for direct use in your code.

When to use Regex Tester

  • Building and iterating on an email, phone number, or URL validation pattern before adding it to a form.
  • Testing a log-parsing regex against a sample log excerpt to confirm it extracts the right fields.
  • Understanding what an existing regex in a codebase actually matches before modifying it.
  • Crafting a search-and-replace pattern for a code editor's find-and-replace with regex mode.
  • Verifying that capture groups in a complex pattern return the expected substrings for all edge-case inputs.
  • Learning regex syntax interactively by writing a pattern and immediately seeing which parts of the test string it matches.

Examples

Extract all email addresses from text

Input: Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} Test: 'Contact alice@example.com or support@utilitykit.tools for help.'

Output: Match 1: alice@example.com (index 8) Match 2: support@utilitykit.tools (index 31)

Named capture groups for ISO date parsing

Input: Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) Test: 'Release date: 2025-11-03, patch date: 2026-01-15'

Output: Match 1: 2025-11-03 → year=2025, month=11, day=03 Match 2: 2026-01-15 → year=2026, month=01, day=15

Case-insensitive word match with i flag

Input: Pattern: error (flags: gi) Test: 'Error logged. ERROR count: 2. Possible errors downstream.'

Output: Match 1: Error (index 0) Match 2: ERROR (index 14) Match 3: error (index 40) Total: 3 matches

Tips

  • Always enable the g flag when testing against a multi-line string — without it, you will only see the first match, which can mislead you into thinking the pattern is more selective than it is.
  • Use named capture groups (?<year>\d{4}) instead of numbered groups in complex patterns — the match list shows group names explicitly, making it much easier to verify multi-field extractions.
  • To match a literal backslash in the test string, you need four backslashes in the pattern field: \\\\ — two for the regex engine and two for the string representation.
  • The \b word-boundary assertion is zero-width, so it does not consume characters. Use it to match whole words (\bword\b) rather than substrings — otherwise 'password' would match a pattern intended only for 'word'.
  • Start with the simplest pattern that could possibly work, then add constraints — it is much easier to narrow a too-broad pattern than to debug a too-complex one that matches nothing.

Frequently Asked Questions

Which regex engine does this tool use?
The tool uses the browser's native JavaScript RegExp engine, which implements the ECMAScript regular expression specification. This means results are accurate for JavaScript code but may differ slightly from PCRE (used in PHP, Python re, Perl) or POSIX regex dialects.
Why does my pattern match nothing even though I think it should?
Common causes include forgetting the g (global) flag when expecting multiple matches, using PCRE syntax not supported in JavaScript (such as \K or possessive quantifiers), or having invisible whitespace in the test string that the pattern does not account for.
How do I test a pattern with special regex characters in the input?
Special characters in the test string (the input you are matching against) need no escaping — only the pattern field uses regex syntax. If you want to match a literal dot, question mark, or parenthesis in the pattern, escape it with a backslash: \., \?, \(.
What is the difference between the m and s flags?
The m (multiline) flag makes ^ and $ match at the start and end of each line rather than just the whole string. The s (dotAll) flag makes the . metacharacter match newline characters as well as all other characters — it has no effect on ^ and $ anchors.
Can I test patterns with lookaheads and lookbehinds?
Yes. The JavaScript engine in modern browsers supports both positive and negative lookaheads ((?=...) and (?!...)) and lookbehinds ((?<=...) and (?<!...)). Lookbehinds require a current-generation browser (Chrome 62+, Firefox 78+, Safari 16.4+).
Why does the g flag matter?
Without the g (global) flag, RegExp.exec finds only the first match and stops. With g, the tool finds all non-overlapping matches across the entire test string and displays each one in the match list. You almost always want g when testing against real data.
Can I use this to test patterns for Python or PHP?
The tool uses the JavaScript engine, so syntax is slightly different from Python's re module or PHP's PCRE. Most common patterns work identically, but Python-specific syntax like (?P<name>...) named groups or PHP-specific modifiers will not work. Use it as a close approximation and verify in the target language.
Is there a risk of catastrophic backtracking with complex patterns?
Yes. Poorly written patterns with nested quantifiers can cause exponential backtracking, making the browser tab appear to freeze. The tool does not impose a timeout by default, so be cautious with patterns like (a+)+ against long strings. If the page becomes unresponsive, refresh to reset.

Explore the category

Glossary

Regular Expression
A sequence of characters that defines a search pattern, used for matching, extracting, and replacing text. Supported by virtually every programming language and most text editors.
Capture Group
A portion of a regex pattern enclosed in parentheses that isolates a matched substring for extraction. Named groups use the syntax (?<name>...) for clearer code.
Flag
A modifier appended to a regex literal that changes matching behaviour — for example, i for case-insensitive, g for global (find all matches), m for multiline anchors, and s for dotAll mode.
Lookahead
A zero-width assertion (?=...) or (?!...) that checks whether a pattern follows the current position without consuming characters. Does not appear in the match.
Quantifier
A symbol that specifies how many times the preceding element must match: * (zero or more), + (one or more), ? (zero or one), {n,m} (between n and m times).
Catastrophic Backtracking
A performance failure caused by patterns with ambiguous overlapping quantifiers, where the regex engine explores an exponential number of match paths, causing near-infinite execution time.