Free Regex Tester & Debugger
Test and debug regular expressions in real-time with explanations. Free, fast, and works entirely in your browser with no sign-up required.
Updated
Regular Expression
Common Patterns Library28
Test Input
Quick Reference (Cheat Sheet)
Privacy First: All processing happens locally in your browser. Your patterns and test data are never sent to any server. History is stored in your browser's localStorage.
Frequently Asked Questions
What is the Regex Tester?
The Regex Tester is a free online tool that lets you test and debug regular expressions in real-time with match highlighting and explanations.
Is the Regex Tester free?
Yes, it is completely free with no registration required. All pattern matching happens client-side in your browser.
Does it explain the regex pattern?
Yes, the Regex Tester provides human-readable explanations of your regular expression patterns to help you understand and debug them.
Is my data safe with this tool?
Absolutely. The Regex Tester & Debugger processes everything client-side in your browser. No data is uploaded to or stored on any server. Your content remains private on your device at all times.
Does the Regex Tester & Debugger work on mobile devices?
Yes, the Regex Tester & Debugger is fully responsive and works on smartphones and tablets. You can use it on any device with a modern web browser -- no app download required.
Do I need to create an account to use this tool?
No account or registration is needed. Simply open the Regex Tester & Debugger in your browser and start using it immediately. There are no sign-up walls or usage restrictions.
How do I use the Regex Tester & Debugger?
Simply enter your input in the provided field, adjust any settings to your preference, and the tool will process it instantly. You can then copy the result to your clipboard or download it.
Which browsers are supported?
The Regex Tester & Debugger works in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. For the best experience, use the latest version of your preferred browser.
What do the g, i, m, s, u, and y regex flags do?
Flags change how the engine applies your pattern. The g (global) flag finds every match instead of stopping at the first. The i (ignore case) flag matches letters regardless of case. The m (multiline) flag makes the ^ and $ anchors attach to each line rather than only the whole string. The s (dotall) flag lets the dot match newline characters too. The u (unicode) flag turns on full Unicode handling and stricter parsing, which matters for emoji and non-Latin text. The y (sticky) flag matches only from the engine's current position, which is useful when tokenizing input piece by piece. Flags can be combined freely, so gi finds every match while ignoring case. This tool exposes all six as toggles, so you can flip them on and off and watch the highlighted matches and the match count update live to see exactly how each one affects your result.
What is catastrophic backtracking and how do I avoid it?
Catastrophic backtracking happens when a pattern has nested or overlapping quantifiers, such as (.*)+ or (a+)+, that force the engine to try an exponential number of ways to match before giving up. On a short, well-formed string it looks fine, but on slightly longer or malformed input the matching time can explode from microseconds to seconds, effectively hanging your program. You avoid it by making quantifiers non-overlapping, using more specific character classes instead of broad ones like .*, and anchoring patterns where possible. This tool flags risky constructs as you type and shows an execution-time badge ranging from Fast to Very Slow, so you can spot a dangerous pattern before it reaches production. The step-by-step debugger, capped at 100 steps so a runaway pattern cannot lock up the page, also lets you watch how the engine reaches each match. Paste your expression above and watch the badge to confirm it stays fast.
What is the difference between a capture group and a non-capturing group?
A capture group, written with plain parentheses like (\d{4}), both groups part of a pattern and stores whatever it matched so you can reference it later by number, or by name with the (?<year>\d{4}) syntax. A non-capturing group, written (?:...), groups a portion of the pattern for applying a quantifier or alternation without saving the matched text, which keeps your group numbering clean and is slightly more efficient. Use capturing groups when you need to extract or reuse a value in a replacement; use non-capturing groups purely for structure. Both kinds can be nested, and quantifiers attach to either, so (?:ab)+ repeats the pair without capturing it. This tool lists every numbered and named capture group alongside the value it pulled from your test string, highlighting each one in the matched text, so you can confirm your groups extract exactly the data you expect before wiring them into code.
How do I use backreferences like $1 in find and replace?
Backreferences let a replacement reuse text captured by your pattern's groups. In replacement strings you reference the first capture group as $1, the second as $2, and so on, so a pattern like (\w+)@(\w+) with the replacement $2.$1 swaps the two halves of a token around the at sign. This is how you reformat dates, reorder names, or rewrite URLs without retyping the matched content. Named groups can also be referenced depending on the syntax your target language supports. Keep in mind that inside the pattern itself a backreference like \1 instead matches the same text the group already captured, which is different from using $1 in the replacement. The find-and-replace mode in this tool previews the substituted output live as you edit the replacement string, with $1, $2, and so on resolving exactly as they would in real code. Switch to the replace tab above to test your substitution before pasting it into your project.
Why does the same regex behave differently in Python or Java?
Regex flavors are not identical across languages. This tool runs the native JavaScript (ECMAScript) engine, the same one used in Node and browsers, but Python's re, Java's Pattern, PHP's PCRE, Go's RE2, and others differ in lookbehind support, named-group syntax, inline flag handling, and how flags are passed. A pattern that works here can need small adjustments elsewhere, especially around Unicode and backreferences. RE2-based engines like Go's even reject some constructs entirely to guarantee linear time. That is why the built-in code generator outputs your finished expression for JavaScript, TypeScript, Python, Java, PHP, Go, Ruby, C#, Rust, and Swift, translating flags into each language's idiom, such as re.IGNORECASE or Pattern.CASE_INSENSITIVE, and noting the quirks each one carries. The safest workflow is to validate against representative sample text here first, since a pattern that looks correct can still miss edge cases in another flavor. Tune your pattern above, then copy the generated code for your target language to avoid flavor surprises.
Embed This Tool
Add a free, live version of this widget to your own website or blog post — it runs entirely in your visitors' browsers, with a credit link back to The Toolbox.
<iframe src="https://getthetoolbox.com/embed/code-tools-regex-tester" title="Free Regex Tester & Debugger — The Toolbox" width="100%" height="320" style="max-width:480px;border:1px solid #e2e8f0;border-radius:12px" loading="lazy"></iframe>
<p style="font-size:12px;margin:4px 0 0"><a href="https://getthetoolbox.com/code-tools/regex-tester?utm_source=embed&utm_medium=widget" target="_blank" rel="noopener">Free Regex Tester & Debugger</a> by The Toolbox</p>Related Tools
Free CSS Minifier Online
Minify CSS code to reduce file size and improve loading speed. Free, fast, and works entirely in your browser with no sign-up required.
Free JavaScript Minifier
Minify JavaScript code to reduce file size and improve performance. Free, fast, and works entirely in your browser with no sign-up required.
Free HTML Minifier Online
Minify HTML code to reduce page size and loading time. Free, fast, and works entirely in your browser with no sign-up required.
Free SQL Formatter & Beautifier
Format and beautify SQL queries for better readability. Free, fast, and works entirely in your browser with no sign-up required.
About the Regex Tester & Debugger
The Regex Tester & Debugger is a free online workbench for building and troubleshooting regular expressions. Type a pattern, paste some sample text, and it highlights every match in real time, lists the capture groups it pulled out, and flags syntax errors the moment they appear. It is built for developers, data wranglers, and anyone who has ever stared at a wall of backslashes wondering why a pattern matches everything or nothing.
Regular expressions are notoriously hard to read, so the tool does more than match. It explains what your pattern is doing, warns you about constructs that can hang the engine, and generates ready-to-paste code in ten languages so the expression you tuned here drops straight into your project.
Everything runs in your browser using the native JavaScript regular-expression engine (the same ECMAScript implementation your code uses in Node and the browser). Nothing you type — pattern, test string, or replacement — is uploaded or stored on a server. There is no sign-up and no usage cap.
How to test and debug a pattern
Enter your expression and toggle any of the six flags that control how it behaves:
- g (global) — find every match rather than stopping at the first.
- i (ignore case) — match letters regardless of case.
- m (multiline) — let
^and$anchor to each line, not just the whole string. - s (dotall) — allow
.to match newline characters. - u (unicode) — enable full Unicode handling and stricter parsing.
- y (sticky) — match only from the engine's current position.
As you edit, matches are highlighted in the test text and every numbered and named capture group is listed with its value. A small execution-time badge labels each run from Fast to Very Slow, and a step-by-step debugger walks through how the engine reaches each match (capped at 100 steps so a runaway pattern can't lock up the page). If you write something like (.*)+, the tool warns you about catastrophic backtracking — nested quantifiers that can make matching time explode on certain inputs.
Replace, batch-test, and export
A find-and-replace mode previews substitutions live, with backreferences such as $1 working exactly as they would in code. The multiline tab lets you check one pattern against many lines at once — handy for validating a column of emails or log entries. When the expression is right, the code generator outputs it for JavaScript, TypeScript, Python, Java, PHP, Go, Ruby, C#, Rust, and Swift, complete with the correct flag translation (Python's re.IGNORECASE, Java's Pattern.CASE_INSENSITIVE, and so on) and notes on each language's quirks. You can copy any result, download it, or share the whole setup as a URL that reloads the pattern, flags, and test string. Recent patterns are kept in your browser's local storage so you can return to them later.
A library of ready-made patterns
If you would rather start from a working example, the built-in library offers around 30 vetted patterns covering the cases that come up most often: email addresses, HTTP/HTTPS URLs, US and international phone numbers, IPv4 and IPv6 addresses, MAC addresses, ISO and US dates, 24-hour times, hex colors, UUIDs, semantic versions, strong-password rules, credit-card formats, URL slugs, Markdown links, and more. Each comes with a description and sample text so you can see it match before adapting it. They are a reliable starting point, but always test against your own data — a "valid email" regex, for instance, can never fully match the email specification, and most production patterns are deliberate trade-offs between strictness and practicality.
Why a tester matters
A regular expression that looks correct can quietly match too much or miss edge cases, and a single misplaced quantifier can turn a fast pattern into one that stalls on real input. Testing against representative samples before shipping catches both problems. Paste your pattern and some text above to see exactly what it matches, understand why, and carry the result into your codebase.