🧪 Regex Tester Online — Free Regular Expression Tester & Debugger

Test, debug, and learn regular expressions with real-time highlighting, match groups, and replace mode. 30+ patterns included.

Need to test a regex fast? This free regex tester online lets you write and debug regular expressions with instant visual feedback — no downloads, no sign-ups, and your data stays 100% private in your browser. Whether you're building form validation, parsing logs, extracting data from HTML, or learning regex for the first time, this regular expression tester gives you everything you need: real-time match highlighting, capture group inspection, flag toggles, and a full replace mode — all in one lightweight page.

Unlike other regex tools that send your data to a server, this online regex tester runs entirely client-side. Your patterns and test text never leave your device. It supports all modern JavaScript regex features — lookaheads, lookbehinds, named groups, Unicode escapes — making it suitable for Node.js, frontend validation, and server-side JavaScript workflows. Below the tool, you'll find a comprehensive regex tutorial with 30+ tested patterns covering email, URL, phone, date, HTML tags, and more — perfect for leveling up your regex skills.

Bookmark this regex tester for your daily development workflow. It's fast, free, and works offline after the initial page load — ideal for the terminal, the coffee shop, or anywhere you need to debug a pattern without an internet connection.

💡 New to regex? Scroll down for our step-by-step regex tutorial and cheat sheet with 30+ proven patterns. Or jump straight to the tutorial →
Invalid regex pattern
g global i case-insensitive m multiline s dotAll
Enter a regex pattern and test text above to see matches highlighted here...
#Full MatchGroupsIndex

🚀 How to Use This Regex Tester

  1. Type your regex pattern in the pattern field. If it's invalid, you'll see an error message immediately. Try copying one of the patterns from the cheat sheet below.
  2. Toggle flags — enable g (global — find all matches, not just first), i (case-insensitive), m (multiline — ^ and $ match line boundaries), or s (dotAll — . matches newlines).
  3. Paste test text — the tool highlights all matches instantly. Each matched piece of text is highlighted in green or purple for easy scanning.
  4. Inspect groups — click any highlighted match or scroll the groups table below the output to see captured groups and their positions.
  5. Switch to Replace mode — enter a replacement string using $1, $2 for captured groups, and see the transformed output in real time.

📋 Regex Cheat Sheet — 30+ Tested Patterns

Click any pattern row to load it into the tester above. Each pattern includes a description and real matching examples.

PatternDescriptionMatches
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\bEmail addressuser@example.com, a.b@co.uk
https?:\/\/[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!$&'()*+,;=]*URL (http/https)https://example.com/path, http://a.co
\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\bIPv4 address192.168.1.1, 10.0.0.255
\b\d{4}-\d{2}-\d{2}\bDate (YYYY-MM-DD)2026-08-03, 1999-12-31
\b\d{2}/\d{2}/\d{4}\bDate (MM/DD/YYYY)08/03/2026, 12/25/2026
\b(?:\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\bPhone number (US/Intl)555-123-4567, (800) 555-1234, +1-800-555-1234
#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\bHex color code#FF5733, #abc, #00FF00
\bpassword\b (word boundary)Word boundary matchingpassword (not passwords)
<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>(.*?)<\/\1>HTML tags (with content)<div>hello</div>, <span class="x">text</span>
\/\*[\s\S]*?\*\/CSS/JS block comments/* This is a comment */
\/\/.*$ (multiline)Single-line comments (//)// this is a comment
^\s*$ (multiline)Empty linesBlank lines in text
\b[A-Z]{2,}\bUppercase acronymsHTML, CSS, API, JSON, SQL
(["'])(?:(?=(\\?))\2.)*?\1Quoted strings"hello world", 'it\'s ok'
\b(\w+)\s+\1\bDuplicate wordsthe the, is is, and and
^(?!.*\b(password|secret|token)\b).*$Lines NOT containing sensitive wordsLines without "password", "secret", "token"
(?<=\/\*)[\s\S]*?(?=\*\/)Lookbehind/lookahead: content inside /**/Extracts just the comment text
\b(?=\w{8,}\b)(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*])\w+\bStrong password (8+ chars, upper/lower/digit/special)P@ssw0rd!, Str0ng#Pass
\b(0?[1-9]|1[0-2]):([0-5][0-9])\s?(AM|PM)\b12-hour time9:30 AM, 12:45PM, 11:00 pm
(?:[A-Z][a-z]+\.?\s)+Proper name (capitalized words)John Smith, Dr. Jane Doe
\b[1-9]\d{2}-\d{2}-\d{4}\bUS SSN format123-45-6789
\b[1-9]\d{4}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}[\dX]\bChinese ID number (18-digit)110101199001011234
\b[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\bUUID v4550e8400-e29b-41d4-a716-446655440000
^(.*)$ (multiline)Match every lineEach line as a separate match
([\w.-]+)\.(jpg|jpeg|png|gif|svg|webp|ico)\bImage filenamesphoto.jpg, logo.svg, banner.webp
\b([A-Za-z_][\w]*)\s*=\s*([^;\n]+)Variable assignmentsname = "Alice", count=42
(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)Strict IPv4 (0-255 each octet)192.168.1.1, 255.255.255.0 (not 999.999.999.999)
^\s+|\s+$ (multiline)Leading/trailing whitespaceSpaces and tabs at line edges
(?<=\d)(?=(\d{3})+$)Thousands separator positionInsert commas: 1234567 → 1,234,567
\b[\w.-]+@[\w.-]+\.\w+\bSimple email (loose)user@example.com

📖 Regex Tutorial — From Beginner to Confident

1. What is a Regular Expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. Think of it as a supercharged Ctrl+F — instead of searching for a literal string like "hello", you can search for patterns like "any word that starts with 'h' and ends with 'o'" (\bh\w*o\b). Regex is built into every major programming language and is essential for form validation, log parsing, data extraction, and text processing.

2. Basic Building Blocks

Literal characters match themselves: abc matches the exact sequence "abc".
Metacharacters have special meaning: . ^ $ * + ? { } [ ] \ | ( ).
To match a literal metacharacter, escape it with \: \. matches a period, \\ matches a backslash.

3. Character Classes

  • [abc] — matches a, b, or c
  • [a-z] — matches any lowercase letter
  • [0-9] — matches any digit (same as \d)
  • [^abc] — matches anything except a, b, c
  • \d — any digit. \D — any non-digit
  • \w — any word character (letter, digit, underscore). \W — any non-word
  • \s — any whitespace (space, tab, newline). \S — any non-whitespace
  • . — any character except newline (or including newline with s flag)

4. Quantifiers — How Many?

  • * — zero or more (greedy). *? — zero or more (lazy)
  • + — one or more. +? — one or more (lazy)
  • ? — zero or one (optional)
  • {n} — exactly n times. {n,} — n or more. {n,m} — between n and m

Greedy vs. Lazy: <.*> on "<div>hello</div>" matches the entire string. <.*?> matches just <div> and </div> separately.

5. Anchors — Where to Match

  • ^ — start of string (or start of line with m flag)
  • $ — end of string (or end of line with m flag)
  • \b — word boundary (between \w and \W)
  • \B — not a word boundary

Example: ^Hello matches "Hello" only at the start. world$ matches "world" only at the end. \bcat\b matches "cat" but not "category" or "scatter".

6. Groups and Captures

  • (...) — capturing group. Matches and remembers the content
  • (?:...) — non-capturing group. Matches but doesn't remember
  • (?<name>...) — named capture group
  • \1, \2 — backreference to captured group 1, 2

Example: (\w+)\s+\1 matches a word followed by itself (useful for finding duplicate words like "the the").

7. Lookarounds — Match Without Consuming

  • (?=...) — positive lookahead: followed by ...
  • (?!...) — negative lookahead: NOT followed by ...
  • (?<=...) — positive lookbehind: preceded by ...
  • (?<!...) — negative lookbehind: NOT preceded by ...

Example: \d+(?=px) matches digits followed by "px" (great for extracting CSS values). (?<=\$)\d+ matches digits preceded by "$" without including the dollar sign.

8. Alternation and Modifiers

  • a|b — matches a OR b
  • (cat|dog) — matches "cat" or "dog" as a group
  • (?i) — inline case-insensitive mode
  • (?m) — inline multiline mode

9. Common Regex Workflows

Form validation: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ validates email addresses on the client side before form submission.

Log parsing: /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/ extracts ISO timestamps from server logs.

Text cleanup: /^[\s\t]+|[\s\t]+$/gm strips leading and trailing whitespace from every line — perfect for cleaning pasted data.

Data extraction: /#([0-9A-Fa-f]{6})\b/g pulls all hex color codes from a CSS file into a structured list.

10. Debugging Tips

  • Start simple: Build your pattern incrementally. Test each piece before combining.
  • Use the flags: Toggle g to see all matches, not just the first one.
  • Watch for greediness: If your .* is eating too much, use .*? instead.
  • Test edge cases: Empty strings, very long inputs, special characters, Unicode — all can break a regex.
  • Bookmark this page: The cheat sheet above is your quick reference — try each pattern in the tester to understand it.

❓ Frequently Asked Questions

What is a regex tester?

A regex tester is a free online tool that lets you write and test regular expressions (regex) in real time. You enter a regex pattern and test text, and the tool instantly highlights all matches. It supports flags like global (g), case-insensitive (i), multiline (m), and dotAll (s), plus a replace mode to transform matched text. All processing is done client-side in your browser — no data is sent to any server.

How do I use this online regex tester?

1. Type your regex pattern in the pattern field (e.g. \b\w+@\w+\.\w+\b for emails). 2. Select flags using the toggle buttons below — g for all matches, i for case-insensitive, m for multiline, s for dot-matches-newline. 3. Paste or type your test text in the text area. The tool highlights matches in real time. 4. Switch to replace mode to see what your text looks like after substitution. 5. Click any highlighted match to see its capture groups.

Can I use this to learn regex?

Absolutely. Below the tool you'll find a comprehensive regex tutorial with 30+ tested patterns covering email validation, URL matching, date parsing, HTML tag extraction, and more. Each pattern includes a description and matching examples — perfect for learning regex step by step. Use the tester to experiment with each pattern in real time.

Is this regex tester free to use?

Yes. No sign-up, no credit card, no usage limits, no ads. It's a community tool for developers. All processing happens in your browser — there's no server to maintain, so there are no costs to pass on.

Is my test data safe and private?

No. Everything happens locally in your browser using the JavaScript RegExp engine. Your patterns, test text, and match results never leave your device. This is especially important if you're testing against sensitive data like customer records, log files, or proprietary code.

What regex flavor does this tester use?

JavaScript's native RegExp engine (ECMAScript specification). It supports all modern features: named groups, lookbehinds (ES2018+), Unicode property escapes (\p{L}), dotAll flag, and sticky flag. It is fully compatible with Node.js and all modern browsers.

Why doesn't my regex match even though it's valid?

Common causes: (1) You forgot the g flag and expect multiple matches. (2) You need the i flag for case-insensitive matching. (3) The . doesn't match newlines — toggle s (dotAll) if needed. (4) Your anchors (^, $) behave differently without the m flag. Enable the flags above and test again.

Can I use this offline?

Yes. Once the page loads, all regex testing runs purely in your browser — no network requests. You can disconnect from the internet and continue debugging your expressions. Save the page locally or bookmark it for airport/coffee-shop coding sessions.

What's the difference between match mode and replace mode?

Match mode highlights all matches and shows capture groups. Replace mode transforms the text — enter a replacement string (like [$1] or REDACTED) and see the result instantly. Use $1, $2 to reference captured groups in your replacement.