Regex Tester
Test and debug regular expressions in real-time with match highlighting.
Why Use Regex Tester?
Regex is unforgiving — one stray backslash or greedy quantifier and your pattern matches everything or nothing. Iterating in a real text editor or running a script each time is slow; pasting sensitive log data into a server-based online tester is worse. This tester gives you instant, in-browser feedback with color-coded matches, numbered capture groups, and a visible index so you can spot off-by-one errors without leaving the page. Perfect for building URL validators, parsing log lines, or sanity-checking that `/\d+/g` really does match every number you expect.
How to Use Regex Tester
- Enter your regular expression pattern in the regex input field.
- Select the appropriate flags (global, case insensitive, multiline, etc.).
- Type or paste your test string in the textarea below.
- View highlighted matches instantly, with detailed match information including capture groups and positions.
Worked Examples
Extract all email addresses
Pattern: /\b[\w.+-]+@[\w-]+\.[\w.-]+\b/g Test: "Contact sales@example.com or support@devpik.com."
Match 1: sales@example.com (offset 8) Match 2: support@devpik.com (offset 30)
The \b boundaries prevent matching fragments inside other words.
Capture timestamp and log level
Pattern: /^\[(\d{4}-\d{2}-\d{2})\]\s+(INFO|WARN|ERROR):/m
Test: [2026-04-15] ERROR: request failedFull match: [2026-04-15] ERROR: Group 1: 2026-04-15 Group 2: ERROR
Numbered groups let downstream code pull out specific fields cheaply.
Validate a hex color
Pattern: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
Test inputs: #fff, #003F87, #xyz, red#fff ✓ • #003F87 ✓ • #xyz ✗ • red ✗
Anchors (^ and $) ensure the entire string matches, not just part of it.
About Regex Tester
A regular expression (regex) is a sequence of characters that defines a search pattern used for matching, finding, and replacing text in strings. The Regex Tester is a free online tool for testing and debugging regular expressions in real-time. As you type your pattern and test string, matches are highlighted instantly with detailed information about each match including capture groups and character positions. Whether you're validating email formats, parsing log files, or extracting data from text, this tool helps you build and verify regex patterns quickly. Includes a built-in cheat sheet for quick reference.
Troubleshooting & Common Issues
My regex matches more than I expected (greedy matching)
Default quantifiers like `.*` and `.+` are greedy — they consume as much as possible and then backtrack. Use the lazy variants `.*?` and `.+?` to match the smallest possible substring instead. For example, `<.*>` matches `<a>hello</a>` entirely, but `<.*?>` only matches `<a>`.
Backslash escapes aren't working the way I'd expect
In the tester, write patterns without the surrounding `/ /` delimiters and without double-escaping — a single backslash is correct (e.g., `\d+`, not `\\d+`). If you're copying the pattern into JavaScript source code, you'll need to double-escape the backslashes in a string literal (`"\\d+"`).
Lookbehind `(?<=...)` is throwing a syntax error
Lookbehind is supported in modern browsers but requires the ECMAScript 2018+ RegExp engine. If your browser is older, rewrite the pattern using captured groups instead — `foo(bar)` with `group[1]` pulled out manually is usually equivalent to `(?<=foo)bar`.
Regex matches on the test page, but my server code doesn't match
Different regex engines differ subtly. This tester uses JavaScript's RegExp engine; Python's `re` and Go's `regexp` are broadly similar, but PCRE (PHP, Perl) supports features JavaScript lacks (possessive quantifiers, recursion). Also check that your runtime is applying the right flags — case-insensitivity in JS requires the `i` flag, in Python you pass `re.IGNORECASE`.
Frequently Asked Questions
What regex flavor does this tool use?
This tool uses JavaScript's native RegExp engine, which supports ECMAScript regex syntax including lookahead, lookbehind, named groups, and Unicode properties.
Does my data leave my browser?
No. All regex processing happens entirely in your browser using JavaScript. No data is sent to any server.
What do the regex flags mean?
g (global) finds all matches instead of stopping at the first. i (case insensitive) ignores letter casing. m (multiline) makes ^ and $ match line starts/ends. s (dotAll) makes . match newlines. u (unicode) enables full Unicode matching.
Can I test regex for other languages like Python or PHP?
This tool uses JavaScript regex syntax, which is very similar to most languages. However, some advanced features like possessive quantifiers or recursive patterns (available in PCRE/PHP) are not supported in JavaScript.
Is there a limit on the test string size?
There's no hard limit, but very large strings (100,000+ characters) may slow down real-time highlighting. For best performance, test with representative samples.
What's the difference between greedy and lazy quantifiers?
Greedy quantifiers (`*`, `+`, `?`, `{n,}`) match as much as possible. Lazy quantifiers (`*?`, `+?`, `??`, `{n,}?`) match as little as possible. Use lazy matching when you want the shortest substring, like extracting content between two markers.
How do I use capture groups to extract parts of a match?
Wrap part of your pattern in parentheses `( )` to create a capture group. You can reference it in code as `match[1]` (first group), `match[2]` (second), and so on. Named groups — `(?<name>...)` — let you reference captures by name instead of number.
Can I use this tool to test regex replacements?
The tester focuses on match highlighting and group display. For replace testing, you can use `$1`, `$2`, etc. in your mental model — the captured groups shown in the tester are exactly what a replace operation would substitute for those references.
Related Tools
JSON Formatter
Format, beautify, validate and convert JSON data with syntax highlighting, tree view, and auto-fix.
Slug Generator
Convert any text or title into a clean, SEO-friendly URL slug.
Text Diff / Compare
Compare two pieces of text to find differences and similarities.
Code Share
Share code snippets online with syntax highlighting and short URLs.
Was this tool helpful?