Skip to content
Free Tool Arena

Developer Utilities · Free tool

Regex Tester

Test regex patterns against sample text with live match highlighting and flag support. This free online tool works instantly in your browser with no signup required.

Updated June 2026

2 matches

  • @12: hello@example.com
  • @33: Support@Acme.io
Found this useful?EmailBuy Me a Coffee

Advertisement

What it does

A free regex tester. Enter a pattern and flags; test against any string and see all matches highlighted in real-time. Capture groups display below each match so you can extract substrings. The pattern explanation panel shows what each piece of your regex does — invaluable when debugging unfamiliar patterns or learning regex syntax.

Regex is both powerful and unforgiving. Common pitfalls: forgetting to escape literal dots (‘.’ matches any character by default), using greedy quantifiers when you wanted lazy ones (‘.+’ vs ‘.+?’), confusing anchors (^ and $) which match string vs. line boundaries depending on the ‘m’ flag, and mixing dialects (PCRE vs. ECMAScript vs. Python re — they have different feature sets). Test patterns here interactively until they behave correctly, then paste into your codebase.

This tester uses the browser’s ECMAScript regex engine. Most modern features are supported: lookahead (?=...), lookbehind (?<=...), named groups (?<name>...), Unicode property classes \p{...}, and sticky flag ‘y’. PCRE-only features like recursion or possessive quantifiers won’t work. For Python re or PCRE-specific patterns, use a tool that targets that engine. See our debugging guide.

Embed this tool on your siteShow snippet

Paste this snippet into any page. Loads on-demand (lazy), no tracking scripts, and sized to most dashboards. Replace the height to fit your layout.

<iframe src="https://freetoolarena.com/embed/regex-tester" width="100%" height="720" frameborder="0" loading="lazy" title="Regex Tester" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px;"></iframe>
Embed docs →

Example input & output

Input

Pattern: \b\w+@\w+\.\w+\b
Flags: g
Text: Contact us at hello@example.com or sales@example.co

Output

2 matches:
hello@example.com
sales@example.co

This is a *rough* email check — real email validation is vastly more complex (RFC 5321). For form input, a lightweight check is usually sufficient; the real validation is sending a confirmation email.

How to use it

  1. Enter your regex pattern.
  2. Set flags (g, i, m, s) as needed.
  3. Paste test text into the input.
  4. Review matches highlighted live.

How it works

Key takeaways

  • Different engines support different features — ECMAScript ≠ PCRE ≠ Python re ≠ Go RE2. A pattern that works in regex101 may fail in your code.
  • Catastrophic backtracking on patterns like (a+)+ can take exponential time on adversarial input — this is how regex DoS attacks happen.
  • Don’t parse HTML with regex. HTML is recursive; regex isn’t. Use DOMParser instead.
  • Lazy quantifiers (*?, +?) are usually what you want for “match between delimiters” patterns — greedy ones over-match.

Uses the browser’s built-in ECMAScript RegExp engine. Your pattern becomes new RegExp(pattern, flags); matches use String.prototype.matchAll() for global flag, String.prototype.match() otherwise.

Advanced: regex dialects + ReDoS

Different engines support different features. ECMAScript (browser + Node.js): lookbehind, named groups, Unicode property classes. PCRE (PHP, Perl, R): adds recursion, possessive quantifiers, branch reset. Python re: similar to PCRE but no recursion. Go: RE2-based, no backtracking, no lookbehind — trades features for guaranteed linear performance. ReDoS (Regular Expression Denial of Service): nested quantifiers like (a+)+ can take exponential time on adversarial input. Run untrusted patterns through a regex tester with timeouts before deploying.

How this compares to alternatives

vs regex101.com: regex101 has more dialect-specific testers (PCRE2, PHP, Java, Python). Ours is JavaScript-only, faster for browser-targeted regex. vs in-editor regex (VS Code, IntelliJ): editor regex matches your target language; faster for code-context matching. vs CLI grep -E / rg: CLI tools are dramatically faster on large file sets; this tool is for one-off pattern development.

Common mistakes when using this tool

  • Forgetting to escape .. Dot matches ANY character. For literal dot, use \.. Pattern www.example.com matches “wwwXexampleYcom” too.
  • Greedy vs lazy confusion. .* matches as much as possible. For matching between quotes, use lazy: ".*?".
  • Mixing dialects. PCRE patterns with possessive quantifiers (a++) won’t parse here. Browser regex is ECMAScript-only.
  • Anchors with multiline flag. ^ and $ match string start/end by default, line start/end with m flag. Most developers want the m flag and forget to add it.
  • Trying to parse HTML. HTML is recursive; regex isn’t. Use DOMParser instead.

Learn more about regex

When to use this tool

  • Building or iterating on a new regex pattern.
  • Comparing behavior of /g vs no /g, or case-insensitive vs case-sensitive.
  • Exploring what a pattern matches across sample text.

When not to use it

  • Parsing HTML or deeply nested structures — use a real parser instead of regex.
  • Performance-critical matching on huge inputs (benchmark in your target runtime).
  • PCRE-only features — browser JavaScript regex has a different (slightly smaller) feature set.

Common use cases

  • Validating an email or phone pattern before pasting it into form validation code.
  • Building a search-and-replace expression for VS Code or editor macros.
  • Debugging why a regex doesn't match the input you expected it to.
  • Testing capture groups before using them in backreferences.

Frequently asked questions

Why does my pattern match here but not in my code?
Flags, escape rules, and regex flavor. Browser JavaScript uses ECMAScript regex. Python, Go, and PCRE each have their own dialect with slightly different syntax. Double-check lookbehind, named groups, and Unicode classes.
How do I make my regex case-insensitive?
Add the 'i' flag. So /hello/i matches 'Hello', 'HELLO', and 'hello'.
What's the difference between greedy, lazy, and possessive quantifiers?
Greedy (default): + and * match as much as possible, then back off. Pattern '.*' on 'abc[xyz]def[ghi]' matches 'abc[xyz]def[ghi]' (everything between first [ and last ]). Lazy: +? and *? match as little as possible. Pattern '.*?' matches 'abc[xyz]def' first, then '[ghi]' separately. Possessive (PCRE/Java, not in JS): ++ and *+ match like greedy but never give back, fail-fast on no match. For matching content between delimiters like quotes or brackets, lazy quantifiers are usually correct: '(".+?")' for quoted strings rather than '(".+")'.
When should I avoid regex?
(1) Parsing HTML / XML — use a real parser (DOMParser, BeautifulSoup, jsoup). HTML is recursive; regex isn't. (2) Parsing JSON — use JSON.parse(). (3) Validating email addresses by RFC 5321 standards — the full email regex is 6,425 characters; most validators use a simplified pattern then send a confirmation email. (4) Performance-critical hot loops on huge inputs — regex can have catastrophic backtracking on adversarial input. (5) Parsing balanced delimiters (matched parens) — regex can't natively handle nesting; use a parser. Rule of thumb: if your regex needs more than 3 levels of conditional logic, you've outgrown regex.
What are common regex 'gotchas' that catch developers?
(1) Forgetting to escape '.' in literal contexts (matches any char by default). (2) Anchors: ^ and $ match start/end of LINE in multiline mode (m flag), otherwise start/end of input. (3) Greedy quantifiers consuming more than intended (use lazy +? *?). (4) Backslash escaping: in code strings, '\d' matches digits but '\\d' is literal backslash-d. (5) Capturing groups vs non-capturing groups: (?:...) doesn't capture, useful when you only want grouping. (6) Lookahead/lookbehind: (?=...) and (?<=...) are zero-width assertions. (7) Unicode: \d matches only [0-9] in some regex flavors, all decimal digits across scripts in Unicode-aware regex.
How do I extract a substring from a regex match?
Use capture groups: parentheses around the part you want to extract. Pattern '(\w+)@(\w+)\.(\w+)' on 'hello@example.com' captures 'hello' (group 1), 'example' (group 2), 'com' (group 3). In JavaScript: 'string.match(pattern)' returns array where index 0 is full match and 1+ are capture groups. Named groups (more readable): pattern '(?<user>\w+)@(?<domain>\w+)' captures into result.groups.user and result.groups.domain. Use match.groups for object access or numbered indices for array access.
Is this regex tester accurate for production patterns?
Yes for ECMAScript / browser / Node.js targets — this tool runs your pattern through the exact same v8/SpiderMonkey/JavaScriptCore engine your production code will use. If you're targeting Python's re module, PHP/Perl/PCRE, Ruby, Go RE2, or Java, run a final check in that flavor's tester (regex101 supports several, or use the language's repl). Behavior differences to watch: lookbehind support (Python and ECMAScript yes; Go RE2 no), recursion (PCRE/Perl yes; most others no), Unicode property classes (varies by version). For 95% of common patterns, ECMAScript-tested patterns transfer cleanly; the remaining 5% involves these advanced features.
How do I write a regex pattern from scratch?
Build incrementally. (1) Start with the literal text you're matching (e.g., '@gmail.com'). (2) Replace exact characters with character classes ('[a-zA-Z0-9]' for alphanumeric). (3) Add quantifiers ('+' for 1 or more, '*' for 0 or more, '{2,4}' for 2-4). (4) Add anchors ('^' for start, '$' for end). (5) Add capture groups '()' around parts you want to extract. (6) Test against 5-10 example strings — both matching AND non-matching, especially edge cases (empty string, special chars, very long inputs). (7) Re-test in the language flavor you'll deploy to. Don't try to write the perfect pattern in one shot; iterate.
What's the best regex tutorial for beginners?
RegexOne (regexone.com) — interactive lessons that build patterns step-by-step. Regular-expressions.info — comprehensive reference covering all flavors with side-by-side comparison tables. The Mozilla MDN regex guide is the best free reference for ECMAScript specifically. For paid courses: 'Mastering Regular Expressions' by Jeffrey Friedl is the canonical book (covers all major flavors, ~$40). Practice strategies: solve regex puzzles on regex-crossword.com, or build patterns for real tasks (validating emails, parsing log files, extracting data from CSVs). Most developers learn regex by need, not by course — pick a real problem, look up the operators you need, build it, repeat.

Advertisement

Learn more

Explore more developer utilities tools

100% in-browserNo downloadsNo sign-upMalware-freeHow we keep this safe →

Found this useful?

The tools stay free thanks to readers who chip in or spread the word.

Buy Me a Coffee