Regex Tester

Write a regular expression and see matches highlighted in your test text in real time. Supports g, i, m, and s flags, capture groups, and common patterns.

Enter a regex pattern — matches highlight instantly as you type
//g
Quick patterns:

Test Text

Matches

Enter a pattern above

Matches will be highlighted here instantly as you type.

Regex Cheat Sheet

Character Classes

.Any character except newline
\dDigit [0-9]
\DNon-digit
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace

Anchors

^Start of string (or line with m)
$End of string (or line with m)
\bWord boundary
\BNon-word boundary

Quantifiers

*0 or more (greedy)
+1 or more (greedy)
?0 or 1 — optional
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*? +? ??Lazy (non-greedy) versions

Groups & Lookarounds

(...)Capturing group
(?:...)Non-capturing group
(?<name>...)Named capturing group
(?=...)Positive lookahead
(?!...)Negative lookahead
(?<=...)Positive lookbehind
(?<!...)Negative lookbehind

Character Sets

[abc]Match a, b, or c
[^abc]Match anything except a, b, c
[a-z]Any lowercase letter
[0-9]Any digit
[a-zA-Z0-9_]Same as \w

About this tool

A fast, browser-only regex tester with live match highlighting. As you type your pattern, every match is highlighted in the test text with colour-coded markers and listed in the results panel with its position, matched string, and any capture groups. No delay, no button to click — results update on every keystroke.

Supports all four JavaScript regex flags: g (global), i (case-insensitive), m (multiline), and s (dotAll). Quick-load common patterns — Email, URL, Phone, IP Address, Date, Hex Color, UUID, ZIP Code — with one click. A full cheat sheet covering character classes, anchors, quantifiers, groups, and lookarounds is always visible at the bottom.

How to use

1

Enter your pattern

Type a regular expression into the pattern field. The input is shown in /pattern/flags notation. Any syntax errors are reported instantly below the field.

2

Toggle flags

Enable g, i, m, or s flags with the toggle buttons next to the pattern field. Flags take effect immediately — no need to re-enter your pattern.

3

Paste your test text

Type or paste the text you want to test in the left panel. Matches are highlighted in colour as you type. Use the common pattern chips to load a ready-made example.

4

Inspect the results

Each match appears in the right panel with its position, matched value, and capture groups. Click Copy Pattern to copy the pattern in /pattern/flags format for use in code.

Frequently asked questions

Common questions about regular expressions, flags, capture groups, and how to use this tool.

A regular expression (regex) is a sequence of characters that defines a search pattern. It can match specific strings, character classes, repetitions, and positions within text. Regex is supported in virtually every programming language and is used for input validation, text search and replace, log parsing, data extraction, and more.

g (global) finds all matches instead of stopping after the first one. i (case-insensitive) makes letters match both upper and lower case. m (multiline) changes ^ and $ to match the start and end of each line instead of the whole string. s (dotAll) makes the dot (.) match newline characters, which it normally skips. You can combine any flags.

The .* quantifier is greedy — it matches as many characters as possible and then backtracks only if necessary. The .*? quantifier is lazy (non-greedy) — it matches as few characters as possible, expanding only when the rest of the pattern fails. For example, on the string '<a><b>', the greedy <.*> matches the whole string while the lazy <.*?> matches just '<a>'.

A capture group is created with parentheses, for example (\d{4}). Text matched inside the group is saved separately and can be referenced as $1 (or \1 in some contexts) during replacement. Named groups use the syntax (?<name>...) and are referenced as $<name>. Non-capturing groups (?:...) group without saving. This tool displays all captured groups for each match in the results panel.

Lookaheads and lookbehinds are zero-width assertions — they check what comes before or after the current position without consuming characters. Positive lookahead (?=...) matches if the pattern ahead succeeds. Negative lookahead (?!...) matches if it fails. Positive lookbehind (?<=...) and negative lookbehind (?<!...) check behind the current position. They are useful for matching text only when surrounded by certain context.

The most common reasons are: missing the g flag (so only the first match is found), greedy vs lazy quantifiers (use .*? to match the shortest possible string), or not anchoring with ^ and $. Also check character classes — [a-Z] is not the same as [a-zA-Z], and a dot matches any character unless escaped with \. Testing each part of the pattern separately using groups is a good debugging technique.

No. All regex matching runs entirely in your browser using JavaScript's built-in RegExp engine. Your patterns and test text are never sent to any server. The tool works offline once the page has loaded.