Enter a pattern and test string to see matches
Write and test regular expressions with live match highlighting and a detailed group capture view. Supports all JavaScript RegExp flags. Runs entirely in your browser — nothing is sent to a server.
Enter a pattern and test string to see matches
A regular expression (regex) is a sequence of characters that defines a search pattern. In JavaScript — and virtually every other programming language — regex enables you to match, extract, validate, and transform strings far more powerfully than simple string methods. A single regex pattern like /^[\w.-]+@[\w.-]+\.\w{2,}$/ can validate an email address that would otherwise require dozens of lines of imperative code.
Regex is the right tool when you need to validate input formats (emails, phone numbers, URLs, postcodes), extract structured data from unstructured text (log parsing, scraping), perform find-and-replace with conditional logic, or tokenize and split strings on complex boundaries. The key to writing good regex is testing it interactively — which is exactly what this tool is built for. Enter your pattern and test string above and the engine highlights every match in real time as you type.
. any char · \d digit · \w word char
* 0+ · + 1+ · ? 0 or 1 · {n,m} range
^ start · $ end · \b word boundary
[abc] char class · (a|b) alternation
(pattern) — captures and assigns group index
(?<name>pattern) — named capture group
(?:pattern) — non-capturing group
$1, $2 in replace
g — global: find all matches, not just first
i — case insensitive: A matches a
m — multiline: ^/$ match each line
s — dotall: . also matches \n
(?=...) — positive lookahead
(?!...) — negative lookahead
(?<=...) — positive lookbehind
(?<!...) — negative lookbehind
[\w.-]+@[\w.-]+\.\w{2,}
https?:\/\/[\w./?=-]+
#[0-9a-fA-F]{3,6}
\d{4}-\d{2}-\d{2}
RegExp engine — zero deps
Catastrophic backtracking (also called ReDoS — Regex Denial of Service) occurs when a regex engine explores an exponential number of paths through the pattern against a string that doesn't match. The classic trigger is nested quantifiers on overlapping character classes, such as (a+)+ or (\w+\s*)+ applied to a long input that nearly matches but ultimately fails. On long strings this can freeze a browser tab or take a server down.
The safest mitigation is to prefer atomic groups or possessive quantifiers where your regex engine supports them, be specific with character classes (use [0-9] rather than \d if you only want ASCII digits), avoid ambiguity between alternation branches, and always test your patterns against adversarial inputs that are long and don't match. This tester shows execution time so you can spot slow patterns early.