Regex Tester

Test regular expressions against text in real-time. See matches highlighted with capture groups.

Free Runs in your browser
//

How to use

  1. 1 Enter your regular expression in the Pattern field and set any flags (g, i, m, s).
  2. 2 Paste or type your test string in the Test input area.
  3. 3 All matches are highlighted in real time. Capture groups are shown in a table below.
  4. 4 Use the match count and group details to debug and refine your expression.

Key features

  • Real-time match highlighting as you type — no button needed
  • Supports all JavaScript regex flags: g, i, m, s, u, y
  • Shows match count, full matches, and all capture group values
  • Useful for debugging email validators, URL matchers, and text parsers

What is a Regular Expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. Regex engines scan text looking for substrings that match the pattern. They're built into virtually every programming language and text editor. JavaScript uses the ECMA-262 regex engine, which supports most standard features — lookaheads, backreferences, named capture groups — but intentionally excludes some advanced features like lookbehinds in older versions and recursive patterns.

Regex operates in different modes controlled by flags: g (global — find all matches), i (case-insensitive), m (multiline — ^/$ match line boundaries), and s (dotall — . matches newlines too).

Common Use Cases

Input validation

Validate emails, phone numbers, postal codes, credit cards, and other structured inputs on the client or server side.

Text extraction

Pull specific data out of unstructured text — log lines, HTML output, clipboard data, or scraping results.

Search and replace

Use capture groups and back-references to reformat text, reorder date parts, or normalize inconsistent data.

Log parsing

Parse access logs, application logs, or error traces to extract IP addresses, status codes, error messages, and timestamps.

Linting and code analysis

Linters and static analysis tools rely on regex to detect forbidden patterns (e.g. console.log, TODO comments).

URL routing

Web servers and routers (Express, Nginx, Apache) use regex to match URL patterns and extract path parameters.

Quick Syntax Reference

The patterns you'll actually use most often.

.Any character except newline
^Start of string (or line in /m mode)
$End of string (or line in /m mode)
\dA digit [0–9]
\wWord character [a–zA–Z0–9_]
\sWhitespace (space, tab, newline)
*0 or more of the preceding element
+1 or more of the preceding element
?0 or 1 (makes the preceding optional)
{n,m}Between n and m repetitions
(abc)Capture group
(?:abc)Non-capturing group
(?=abc)Lookahead: followed by "abc"
[abc]Character class: a, b, or c
[^abc]Negated class: anything but a, b, c
a|bAlternation: match a or b