Home Developer Tools Regex Tester
🔍
Dev

Regex Tester

Write, test, and debug regular expressions against any text. Live match highlighting, capture group inspection, global/multiline/case-insensitive flags, and a built-in pattern library. 100% browser-based.

⚡ Live highlighting( ) Group inspector📚 Pattern library🚩 All JS flags
Switch Tool:
🔒 100% Private — All processing runs entirely in your browser. Nothing is sent to any server.
/ /

📖How to Use the Regex Tester

  1. 1
    Enter your regex pattern

    Type your regular expression into the pattern field (without surrounding slashes). Select your flags — g (global), i (case-insensitive), m (multiline), s (dotAll) — using the toggle buttons. The pattern is compiled using JavaScript's native RegExp engine.

  2. 2
    Paste your test string

    Paste the text you want to test against in the input field below. Matches are highlighted in real time as you edit either the pattern or the test string. The match count, positions, and full/partial match details appear instantly.

  3. 3
    Inspect matches and groups

    Each match is shown with its full text, start/end index, and all named and unnamed capture groups. Use the Replace tab to test regex replacement with a substitution string. Browse the built-in pattern library for common regex patterns (email, URL, phone, IP, date formats).

💡Quick Reference

TokenMatches
.Any char (not \n)
\d / \w / \sDigit/Word/Space
^ / $Start / End
* / + / ?0+ / 1+ / 0 or 1
{n,m}n to m times

Frequently Asked Questions

What regular expression engine does this use?

This tool uses JavaScript's native RegExp engine, implemented via new RegExp(pattern, flags). This means patterns are validated and matched exactly as they would be in a browser or Node.js environment. JavaScript regex syntax follows the ECMAScript specification and supports most standard regex features including lookaheads, lookbehinds (ES2018+), named capture groups, Unicode mode (u flag), and the sticky flag (y).

What do the regex flags mean?

The g (global) flag finds all matches rather than stopping at the first. The i (case-insensitive) flag makes matching case-insensitive. The m (multiline) flag makes ^ and $ match the start and end of each line rather than the entire string. The s (dotAll) flag makes . match newline characters (\n). The u (Unicode) flag enables proper Unicode matching. The y (sticky) flag matches only from the lastIndex position.

What is the difference between a match and a capture group?

A match is the entire portion of text that matches the regex pattern. A capture group is a part of the pattern wrapped in parentheses () that captures just that portion of the match separately. For example, the pattern (\d{4})-(\d{2})-(\d{2}) matches a date like 2024-01-15 and captures three groups: 2024, 01, and 15. Named groups use (?<name>...) syntax and are accessible by name.

What are lookaheads and lookbehinds?

Lookaheads and lookbehinds are zero-width assertions that match based on what comes before or after a position without including that context in the match. A positive lookahead (?=...) matches if the pattern ahead is present. A negative lookahead (?!...) matches if the pattern ahead is absent. Similarly, (?<=...) is a positive lookbehind and (?<!...) is a negative lookbehind (JavaScript ES2018+). Example: \d+(?= dollars) matches numbers followed by " dollars" without including " dollars" in the match.

Why does my regex work in one language but not another?

Regular expression syntax varies between languages and engines. Key differences include: \w, \d, \s behaviour with Unicode (JavaScript \w does not match accented letters), lookbehind support (Python yes, older JS no), possessive quantifiers and atomic groups (PHP/Java yes, JS no), backreferences in character classes (varies), and POSIX classes like [:alpha:] (not supported in JavaScript). This tool tests against JavaScript's RegExp engine specifically.

What are some common regex patterns for validation?

Common patterns include: email addresses (the deceptively complex RFC 5321 — use a library for production), URLs (https?:\/\/[\w\-]+(\.[\w\-]+)+\S*), IPv4 addresses ((\d{1,3}\.){3}\d{1,3}), phone numbers (vary enormously by country — use a dedicated library like libphonenumber), dates (\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])), and hex colours (#[0-9a-fA-F]{3,6}). Use the built-in pattern library in this tool for ready-to-use examples.

What is catastrophic backtracking?

Catastrophic backtracking occurs when a regex with nested quantifiers (e.g. (a+)+ or (\w+\s*)\w+) takes exponential time to determine that a string does not match. An attacker can use this to cause a denial-of-service (ReDoS) by sending a specially crafted input. Always test regex performance with non-matching inputs and avoid patterns with nested quantifiers over the same characters. This tool shows match time to help identify slow patterns.