Regex Tester

Free regex tester. Test JavaScript regular expressions live with highlighted matches, capture groups, and flag toggles — i, g, m, s, u, y all supported.

Quick answer

Regex (regular expression) is a pattern language for matching strings. \d+ matches one or more digits. [A-Z] matches one uppercase letter. (foo|bar) matches 'foo' or 'bar'. The tester runs your pattern against any input live and highlights matches.

Regex Tester

Matches

How it works

Compiles your pattern as a JavaScript RegExp with the flags you specify, then runs matchAll against your test string and lists every match with its position. Common flags: g (global, find all matches), i (case-insensitive), m (multiline, ^ and $ match line boundaries), s (dotall, . matches newlines).

When to use it

Testing patterns before pasting them into code, validating user input formats, extracting data from messy text, or learning regex by experimenting.

Common mistakes

Forgetting to escape literal special characters — to match a real period, write \., not . (which matches anything). JavaScript regex has minor differences from Python or PCRE; don't assume patterns from other languages work as-is.

How the regex tester works

You enter a regex pattern (without the surrounding slashes), pick flags (g for global, i for case-insensitive, m for multiline, s for dotall), and a test input. The tool runs the JavaScript RegExp engine against the input and highlights every match. For patterns with capture groups, each group's value is displayed alongside the match. Invalid patterns show a parse error so you can fix syntax before running.

When to use it

Building input validation patterns (email addresses, phone numbers, postal codes). Extracting structured data from log lines, scraped HTML, or unstructured text. Refining a regex iteratively against real test data before shipping it to production code. Learning regex syntax — type a pattern, watch what it matches, adjust.

Common mistakes

Frequently asked questions

What is a regular expression?

A regex (regular expression) is a pattern language for describing sets of strings. \d matches a digit, [a-z] matches a lowercase letter, .* matches anything. Regex powers find-and-replace, validation, and text extraction across virtually every programming language.

What's the difference between . and \.?

. (unescaped) is a regex wildcard — it matches any single character except newline. \. (escaped with backslash) matches a literal dot character. To match a period in 'example.com', you need \..

Why is my regex matching too much?

Almost always greedy quantifiers. .* matches as much as possible — including past the closing delimiter you intended. Switch to lazy: .*?. For matching paired delimiters cleanly, use a more specific pattern like [^"]* instead of .*.