Regex Tester — Test Regular Expressions Online

Free regex tester & regular expression testertest regex online instantly. Enter pattern with flags g,i,m,s,u,y, paste test string, see highlighted matches, capture groups & replace. Client-side, no signup.

⚙️ new RegExp() live🎯 Highlight + Groups + Replace🚩 g i m s u y📋 Copy & ⬇ Download⚡ 100% Client-Side

⌨️ Input Regex Pattern

Flags: g • Valid:
/ /
Quick insert:

📝 Test String

Chars: 0 • Lines: 0 • Size: 0 B
new RegExp(pattern, flags) • live highlight • groups • replace

📤 Matches

Matches: 0 • Groups: 0 • Time: 0ms
No matches yet — enter pattern and test string, then click Test Regex. Matches, capture groups & named groups will list here.
🔁 Replace Supports $1, $2, $&, $`, $' and $<name> — e.g. $1@$2 or <$1>
Replace result will appear here...

What is Regex? Regular Expression Tester Explained

A regex (regular expression) is a pattern that describes a set of strings using literals and metacharacters. A regex tester — also called regular expression tester — lets you test regex online before you ship it to production. Instead of guessing whether ^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$ really validates email, you paste it into our regular expression tester, paste a test string like support@html-compiler.com, and see instantly if it matches, what groups it captures, and how replace behaves. At html-compiler.com/regex-tester/ we run new RegExp(pattern, flags) directly in your browser — the exact same engine your HTML form validation and JavaScript .test() / .match() will use. No server, no upload, zero latency. Search terms regex tester, regular expression tester, test regex online, regex checker, regex validator, online regex tester all point here — one lightweight page covers them all.

How regex works: every character is either a literal (a matches a) or a metacharacter (. any char, \d digit [0-9], \w word [A-Za-z0-9_], \s whitespace, ^ start, $ end, \b word boundary). Quantifiers (* 0+, + 1+, ? 0/1, {2,4} range) control repetition. Groups (...) capture, (?:...) non-capturing, (?<name>...) named capture, [abc] character class, [^abc] negated, a|b alternation. Flags (gim) modify matching globally. Our test regex online tool highlights every match so you see the pattern in action rather than reading theory alone.

Why Test Regular Expressions? Benefits of a Regex Tester

Writing regex without testing is like writing HTML without preview — invisible errors ship. A missing escape (. vs \.), a greedy .* that over-matches <div>...</div>, or a forgotten flag i that misses Hello vs hello can break validation and leak bad data. A regex tester makes those bugs visible instantly.

BenefitHow Regex Tester HelpsWho Benefits
👁️ Visual ConfirmationOrange/blue highlights show exactly what matched and where — not just true/falseBeginners learning \d, \w, quantifiers
🐛 Catch Syntax Errors EarlyInvalid regular expression: Unterminated group explains unclosed ( or [ before deployFrontend devs doing form validation
🎯 Learn Capture GroupsLists $1, $2 and named $<name> with indices so you master replace and matchAllJS developers parsing HTML/URLs
⚡ Faster IterationEdit pattern like \d{2}\d{3} and re-test in 200ms — no console reloadAll developers, QA
🔁 Test Replace LogicReplace (\w+)@(\w+) with [$1 at $2] preview prevents broken sanitizationBackend, email templates
🔍 HTML Validation ParitySame RegExp engine as <input pattern> and JS pattern.test() — what you see is what shipsHTML form authors

Beyond debugging, a regular expression tester is a teaching lab. Students paste a paragraph, try \b[A-Z][a-z]+\b to find capitalized words, and see language theory become interactive. That hands-on loop — hypothesis, test, highlight — is why searches for test regex online grow 15% yearly.

Regex Syntax Cheat Sheet — Patterns You Will Test Online

Keep this table open beside the tester. Every row is directly testable via new RegExp:

SyntaxMeaningExampleMatches
.Any char except newline (with s flag includes newline)a.cabc, a1c
\d \DDigit [0-9] / non-digit\d+2026 in price $19.99
\w \WWord [A-Za-z0-9_] / non-word\w+hello, user_1
\s \SWhitespace / non-whitespace\s+spaces, tabs
^ $Start / end of string (with m → line)^HelloHello World (start)
[abc] [^abc]Character class / negated[A-Z][a-z]+Hello
* + ?0+, 1+, 0/1 quantifiersa+aaa
{n} {n,} {n,m}Exact / at least / range\d{2,4}2026, 99
(...) (?:...)Capture / non-capture group(ab)+abab group ab
(?<name>...)Named capture group(?<year>\d{4})2026 → groups.year
a|bAlternation (or)cat|dogcat or dog
\b \BWord boundary / non-boundary\bword\bword alone, not password
(?=...) (?!...)Positive / negative lookahead\d+(?= dollars)19 in 19 dollars
(?<=...) (?<!...)Lookbehind (needs u safe)(?<=\$)\d+19 in $19
\p{L}Unicode property (needs u)\p{Emoji}🚀, ✓

Quantifier greediness matters: .* is greedy (<div>a</div><div>b</div> matches all), .*? is lazy (matches first div only). Test both in our regex tester to see highlight shrink from orange covering everything to just first tag — a classic HTML parsing lesson.

Regex Flags Explained — g, i, m, s, u, y for Test Regex Online

Flags after /pattern/flags change how RegExp runs. Our tester syncs checkboxes and the flags textbox — toggle any flag and re-test:

FlagNameWhat It DoesWhen to Use in Tester
gGlobalFind all matches, not just first; enables matchAll + lastIndex loopCount emails in paragraph; without g you see only first email
iIgnoreCaseCase-insensitive: a matches A/hello/i matches Hello, HELLO
mMultiline^ and $ match start/end of each line (split by \n)^# with m finds markdown headings per line
sDotAll. matches newline \n too.* with s matches multiline HTML block
uUnicodeEnable \p{}, correct surrogate pairs, strict escapesMatch emoji \p{Emoji} or accented é
yStickyMatch only at lastIndex position (anchored)Tokenizer loop — advanced, test with y + manual lastIndex

Combine flags like gim — order does not matter, duplicates are rejected by new RegExp (we deduplicate and sort). Example: test hello on Hello\nhello\nHELLO. No flags → 0 (case miss). i → 1 match. gi → 3 matches. gim with ^hello → also 3 because m lets ^ match each line start. Try these in the tester to feel flag interaction.

How to Use Regex Tester — Step-by-Step Guide

Step 1: Enter Pattern & Flags

In ⌨️ Input Regex Pattern type pattern without surrounding slashes — e.g. ([a-z0-9._%+-]+)@([a-z0-9.-]+\.[a-z]{2,}). Flags default to g (global). Toggle i for case-insensitive, m for multiline ^$, s if you need . to cross lines. The flags textbox and checkboxes stay in sync — editing one updates the other. Use quick-insert chip buttons (\d, \w, \s, .*, (.*), (?<name>)) to avoid typing escapes. The pattern border turns red and an error box appears if syntax is invalid — e.g. unclosed [ shows Invalid regular expression: Unterminated character class.

Step 2: Paste Test String

In 📝 Test String paste any text: emails, HTML snippet, logs, CSV, or multiline paragraph. Click 📋 Paste to read clipboard via navigator.clipboard.readText(), 📁 Upload to load a .txt/.html/.json file via FileReader (up to ~5MB, UTF-8), or type manually. Stats show Chars / Lines / Size live. For HTML validation, paste realistic markup like <div class="card"><h1>Hello</h1><p>Price $19.99</p></div> to test HTML-tag regexes.

Step 3: Click Test Regex & Read Results

Hit orange ▶ Test Regex (or Ctrl + Enter). We run:

const regex = new RegExp(pattern, flags); // try/catch for SyntaxError
const matches = flags.includes('g')
  ? [...testString.matchAll(regex)] // global: all matches
  : (testString.match(regex) ? [testString.match(regex)] : []);

Results in 📤 Matches: top highlight view shows test string with each match wrapped in <mark> (orange / blue zebra), below a list per match with Match # — index: 12, full match in monospace box, then group chips: $1: html-compiler, $2: com, and named groups like user: support. Stats update to Matches: 3 • Groups: 6 • Time: 1.2ms. If zero matches, we show “No matches — try adding i flag or escaping”.

Step 4: Test Replace & Export

Optional: in 🔁 Replace type replacement like [$1], $<user>@$<domain>, or ***, then click Replace — we run testString.replace(regex, replacement) and show result with diff length. Use $& (full match), $1..$9 (capture), $` (before), $' (after), $$ (literal $). Then 📋 Copy copies highlights + match list + replace as formatted text via Clipboard API, ⬇ Download saves regex-results.txt (Blob). ⛶ Full Screen opens Matches card via Fullscreen API for large logs.

Pro tip: Enable flag g for count, disable for single-match group inspection — groups are clearest without global noise.

Common Regex Examples to Test Online (Copy & Try)

Try each pattern in the tester with flag g (add i where noted) and the sample test string:

Use CasePatternFlagsTest String SampleWhat You See
Email([a-z0-9._%+-]+)@([a-z0-9.-]+\.[a-z]{2,})gisupport@html-compiler.com, Sales@Example.ORG2 matches, groups: user + domain
URLhttps?:\/\/[^\s]+gVisit https://html-compiler.com/regex-tester/ and http://example.com2 URLs highlighted
Phone\+?\d{1,3}[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}gCall +1 (555) 123-4567 or 555.123.4567Both phones captured
HTML Tag<([a-z]+)[^>]*>(.*?)<\/\1>gi<div>hi</div><p>bye</p>Tags + inner content groups
Price\$\d+\.\d{2}g$19.99, $29.50$ prices only
IPv4\b(?:\d{1,3}\.){3}\d{1,3}\bg192.168.1.1, 10.0.0.1IPs highlighted
Date YYYY-MM-DD\b\d{4}-\d{2}-\d{2}\bg2026-09-04Date match
Named Groups(?<user>\w+)@(?<domain>\w+\.\w+)galice@example.comgroups.user, groups.domain
// HTML validation example: test if input is valid email before form submit
const emailRe = new RegExp(String.raw`^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$`, 'i');
console.log(emailRe.test('support@html-compiler.com')); // true
console.log(emailRe.test('bad@')); // false

// Extract HTML tag names and content with groups
const tagRe = /<([a-z]+)[^>]*>(.*?)<\/\1>/gi;
const html = '<h1>Title</h1><p>Hello</p>';
for (const m of html.matchAll(tagRe)) {
  console.log(m[1], m[2]); // h1 Title , p Hello
}

Regex for HTML Validation — Use the Tester for Forms & Scraping

HTML forms rely on regex via <input pattern="..."> and JavaScript validation — the same RegExp our tester uses. Before you set pattern="^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" on an email input, test it here against good/bad samples: valid@mail.com ✓ vs no-at.test ✗. For HTML scraping, regex helps but with caution: never parse full HTML with regex alone (use DOMParser), but regex is perfect for quick tag/attribute extraction in trusted snippets. Test <([a-z0-9]+)[^>]*\sclass="([^"]+)" to extract class names, or href="([^"]+)" to pull links from a pasted HTML fragment. The tester’s highlight makes over-matching obvious — if .* eats two adjacent <div>s, switch to .*? (lazy) and see highlight shrink to per-tag. Combine with HTML entity awareness: test &(?:amp|lt|gt|quot); to find encoded entities before decoding via our HTML Entity Encoder. Pro workflow: validate in regex tester → copy pattern → paste into <input pattern> → test form → ship. Keywords html validation regex, pattern attribute regex, form validation regex are long-tail traffic we capture precisely because this section bridges regex and HTML.

Regex Tester vs Console & Manual Testing — Comparison

MethodSpeedVisualGroups & ReplaceError Help
html-compiler.com Regex TesterInstant, 1 click✅ Orange/blue highlights + index✅ Capture + named groups + replace preview✅ Red box with SyntaxError message
Browser Console (/re/.test())Manual typing❌ true/false onlyManual matchThrows uncaught error
Desktop regex (VS Code search)Fast but no groups list⚠️ Yellow highlight onlyPartialNo flag helper
Other online testersOften ads, server logBasicVariesSometimes silent

We love console for quick RegExp checks, but for “show me all matches and groups” our online tester wins: zero setup, shareable pattern via copy, private (no server), and identical engine to production HTML validation. It mirrors htmlbeautifier.org’s light, friendly card UI (📥 Input / 📝 Test String side emphasis, centered orange Test, 📤 Matches stats) but upgrades for regex with flag pills, quick-insert chips, and zebra highlights — no bloat, under 15KB local JS + native RegExp.

Pro Tips, Pitfalls & Browser Compatibility

Compatibility: Chrome 90+, Firefox 90+, Safari 14+, Edge 90+ — uses only RegExp, String.prototype.matchAll, Clipboard API, FileReader, Blob, Fullscreen API with graceful fallbacks. Lookbehind (?<= ) and \p{} need modern browsers (2020+); if unsupported, tester shows SyntaxError — remove u or lookbehind.

Target Keywords & Search Intent Map (SEO Authority)

We built this page to rank for the full cluster around regex tester — covering tool and learning intents naturally:

Primary KeywordMonthly Volume*IntentHow We Cover It
regex tester9,900ToolTitle, H1, hero, URL /regex-tester/, button, JSON-LD
regular expression tester3,600ToolH1, description, H2, FAQ synonyms
test regex online2,900ToolHero, how-to, meta description, FAQ
regex checker / validator1,600ToolError box, syntax section, FAQ “invalid regex”
online regex tester / regex1012,200ToolComparison table, features, hero badges
regex flags g i m720InformationalFlags table, interactive flag pills
html validation regex590Tool + LearnHTML validation section, email/tag examples

*Estimated volumes for illustration — we target variants naturally through H2s, code tables, and FAQPage schema for featured snippets.

Frequently Asked Questions (FAQ)

What is regex and how does a regex tester work?

Regex (regular expression) is a pattern language for matching text — using literals, metacharacters like \d, \w, ., *, +, ^, $, [abc], ( ) and flags. A regex tester takes your pattern string and flags, constructs new RegExp(pattern, flags), then executes it against your test string. Internally we use testString.matchAll(regex) for global or testString.match(regex) for single, iterating matches to extract match[0] (full), match[1..n] (capture groups), match.index (position), and match.groups (named). Highlights are built by escaping HTML and wrapping each match in <mark>. Invalid syntax is caught via try/catch (e instanceof SyntaxError) and shown in red — no crash.

How do I test regex online with flags g, i, m?

Enter pattern without slashes (e.g. hello), set flags in the textbox or click pills. g = global (all matches), i = case-insensitive, m = multiline (^/$ per line), plus s (dotAll), u (unicode), y (sticky). Paste test string like Hello hello HELLO. Click Test Regex. With i you get 3 matches; without, only lowercase hello. With m, ^hello matches each line start. Our flags sync: checking a pill updates the textbox and vice versa. Pattern (?<word>\w+) with g and test “one two” shows 2 matches each with named group.

Why does my regex show error “Invalid regular expression”?

Common causes: unclosed group (abc, unclosed class [abc, lone quantifier *, invalid escape, or double flag gg. JavaScript throws SyntaxError: Invalid regular expression: /pattern/flags: .... Our tester catches this and shows exact message in red box below pattern. Fix checklist: close every ( with ), every [ with ], escape literal . as \., ensure flags are only from gimsuy and not duplicated. For lookbehind (?<= ) or \p{}, you need modern browser and flag u — older throws.

Can I test HTML validation regex for email and tags?

Yes. For email validation (HTML form pattern), test ^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$ with flag i on samples: support@html-compiler.com ✓, bad@ ✗, no-at.test ✗. For HTML tag extraction, test <([a-z]+)[^>]*>(.*?)<\/\1> with gi on <div class="x">hi</div> — you get group 1 = tag name, group 2 = inner. Use .*? (lazy) not .* to avoid over-matching. Always anchor validation patterns with ^$ when checking whole input; omit for search.

What is the difference between match, groups and replace in tester?

Match = full substring that satisfied pattern (match[0]). Groups = captured parentheses (...)$1, $2 and named (?<name>...)groups.name. Replace = what you get after testString.replace(regex, replacement) where replacement can reference groups via $1, $<name>, $& (full match), $` (before), $' (after). Example: pattern (\w+)@(\w+), replacement [$1 at $2] transforms alice@example[alice at example]. Our tester shows all three: highlight (match), chips (groups), and replace output.

Is this regex tester free and does it match JavaScript / HTML pattern behavior?

100% free, no signup, 100% client-side — pattern and test string never leave browser, no logs. It uses the native browser RegExp engine, identical to what <input pattern> and String.prototype.match use in your site’s JS/HTML validation. So if it matches here with flag i, it will match in your form. Works offline after first load, on Chrome/Firefox/Safari/Edge 90+. For Python/PHP flavors (PCRE) results are similar but test in that language if you deploy there — JS does not support (?R) recursion etc.

Best Regex Tester Online Free in 2026 — Start Testing Now

Whether you are a student learning regex syntax, a frontend dev validating HTML forms, or an engineer parsing logs, URLs, and HTML tags, a fast regex tester turns trial-and-error into instant feedback. Stop guessing why \d+ misses a price or why <div>.*</div> eats your whole page — paste pattern and test string above, hit orange ▶ Test Regex, and see highlighted matches, capture groups, and replace preview in one view. Bookmark html-compiler.com/regex-tester/ — the lightweight, private, evergreen regex tester and regular expression tester for 2026 and beyond, built to rank for test regex online and to teach you regex while you work. Explore our ecosystem: HTML BeautifierCSS BeautifierJS BeautifierHTML MinifierJSON BeautifierHTML ValidatorBase64 EncoderHTML Compiler — all free, all client-side.