Regex Tester & Builder (JavaScript)

Build and test ECMAScript regular expressions with live highlighting, flags and group details. Private by design—everything runs in your browser.

Pattern, Flags & Text

Tip: Ctrl/Cmd + K focuses the pattern. Ctrl/Cmd + Enter tests.

Results

No results yet.

Matches & Groups

Shows match index, ranges, and capture groups (group ranges require d if supported).

Note: This uses your browser’s ECMAScript regex engine. Some PCRE tokens (e.g., atomic groups) aren’t supported.

Test and learn regular expressions

This regex tester helps you build and validate regular expressions in a clear, interactive way. Regular expressions are patterns used to find, match, or replace text. They are common in programming, data cleanup, form validation, and search tools. With this page, you can see matches instantly and understand how a pattern behaves before you use it in your code.

At a high level, a regex is a recipe for what text should look like. It can match simple things like a single word or complex formats like email addresses, dates, and log entries. The browser highlights each match in your sample text, and capture groups show how parts of the pattern are extracted. This makes it easier to debug and refine your expression.

How to use this regex tester

  1. Enter your regex pattern in the input field.
  2. Paste sample text into the test area.
  3. Toggle flags like case-insensitive or global if needed.
  4. Review highlighted matches and capture group output.

If you are new to regex, start with a short pattern and expand it step by step. You can test changes as you go, which helps you avoid mistakes like matching too much or too little.

Common examples

  • Email: ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
  • IPv4: ^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$
  • ISO date (YYYY-MM-DD): ^\d{4}-\d{2}-\d{2}$

Character classes

. any char · \w/\d/\s word/digit/space · [a-z] ranges

Anchors

^ start · $ end · \b word boundary

Groups & lookaround

(…) capture · (?:…) non-capture · (?=…)/(?!…) lookahead

Quantifiers

*/+/? · {m,n} · +? lazy

Real-world uses

Developers use regex to validate form inputs, parse logs, and clean data in spreadsheets. Content teams use it to find patterns in text or apply bulk edits. Whether you need a regex checker, a regular expression tester, or a quick way to debug pattern matching, this tool gives you a fast, visual workflow.

5 Fun Facts about Regex

Dot isn’t everything

. skips line breaks unless you add /s, and even then it matches code points—not whole emojis. A single emoji can be two code units wide.

Grapheme gotcha

Backtracking blowups

Patterns like (a+)+b on a thousand as can lock the engine, trying millions of paths. Small tweaks (a+b or lazy quantifiers) avoid it.

Performance trap

Indices flag = maps

The modern d flag returns start/end offsets for each capture. Great for highlighting matches without re-running the pattern.

Pinpoint groups

Order really matters

Alternations run left to right. In /(cat|catalog)/, “cat” wins first, so “catalog” never triggers the second branch.

Greedy choices

Born in neuroscience

Regex theory came from neurophysiologist Stephen Kleene in the 1950s. Decades later, grep (1973) brought it to Unix terminals.

Pattern history

Explore more tools