Matches will appear here…
Regex Tester & Expression Builder
Build, test, and debug regular expressions in real time — see highlighted matches and capture groups instantly, no sign-up needed.
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
- 1Enter your regex pattern in the Pattern field (without the surrounding slashes — they're shown automatically).
- 2Toggle the flags you need: g (global) finds all matches, i ignores letter case, m makes ^ and $ match line boundaries.
- 3Paste or type the text you want to search in the Test String textarea.
- 4Matches are highlighted in real time in the Match Preview panel and listed with their capture groups in the panel on the right.
- 5If your pattern is invalid (e.g., an unclosed parenthesis), a red error message appears inline — the rest of the page stays stable.
- 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
| Token | Description | Example |
|---|---|---|
| . | Any character except newline | c.t → cat, cot, cut |
| \w | Word character [a-zA-Z0-9_] | \w+ → hello, foo_1 |
| \d | Digit [0-9] | \d{3} → 123 |
| \s | Whitespace (space, tab, newline) | \s+ → (spaces) |
| \W / \D / \S | Negated 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$ |
| \b | Word boundary | \bcat\b |
Quantifiers & Groups
| Token | Description | Example |
|---|---|---|
| * | 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|b | Alternation — a or b | cat|dog |