Regex Tester & Expression Builder

Build, test, and debug regular expressions in real time — see highlighted matches and capture groups instantly, no sign-up needed.

100% FreeNo Sign-upRuns in BrowserPrivacy First
//g
Flags
Match Preview
Matches will be highlighted here…
Matches & Capture Groups

Matches will appear here…

What is Regular Expression (Regex)?

A regular expression (or regex) is a sequence of characters that defines a search pattern. Regex engines scan text and find substrings that conform to the rules you specify — from simple word searches to complex email validation patterns.

Regular expressions are supported in virtually every programming language — JavaScript, Python, Java, Go, Rust, PHP — and in command-line tools like grep, sed, and awk. They are indispensable for form validation, log parsing, text replacement, and data extraction tasks.

This tool uses JavaScript's native RegExp engine so results are 100% accurate for JS/TypeScript environments. All evaluation happens client-side — your data never leaves your browser.

How to Use the Regex Tester

  1. 1Enter your regex pattern in the Pattern field (without the surrounding slashes — they're shown automatically).
  2. 2Toggle the flags you need: g (global) finds all matches, i ignores letter case, m makes ^ and $ match line boundaries.
  3. 3Paste or type the text you want to search in the Test String textarea.
  4. 4Matches are highlighted in real time in the Match Preview panel and listed with their capture groups in the panel on the right.
  5. 5If your pattern is invalid (e.g., an unclosed parenthesis), a red error message appears inline — the rest of the page stays stable.
  6. 6Click Copy Expression to copy the full /pattern/flags string to your clipboard.

Regex Cheat Sheet

Use this quick-reference table for the most commonly used regex tokens and quantifiers.

Character Classes & Anchors

TokenDescriptionExample
.Any character except newlinec.t → cat, cot, cut
\wWord character [a-zA-Z0-9_]\w+ → hello, foo_1
\dDigit [0-9]\d{3} → 123
\sWhitespace (space, tab, newline)\s+ → (spaces)
\W / \D / \SNegated versions of above\D → a, !, @
[abc]Character class — matches a, b, or c[aeiou] → vowels
[^abc]Negated class — matches anything except a, b, c[^0-9] → non-digits
^Start of string (or line with m flag)^Hello
$End of string (or line with m flag)world$
\bWord boundary\bcat\b

Quantifiers & Groups

TokenDescriptionExample
*0 or more\w*
+1 or more\d+
?0 or 1 (optional)colou?r
{n}Exactly n times\d{4}
{n,m}Between n and m times\w{3,8}
*? / +?Lazy (non-greedy)<.+?>
(abc)Capturing group — $1(\w+)@
(?:abc)Non-capturing group(?:foo|bar)
(?<name>...)Named capturing group(?<year>\d{4})
a|bAlternation — a or bcat|dog