FC

🔍 Regex Tester

Live regular expression testing with match highlighting

//

Matches Highlighted

2 matches
Contact alice@example.com or bob@company.org for support.
Match 1: alice@example.com - groups: ["alice", "example", "com"]
Match 2: bob@company.org - groups: ["bob", "company", "org"]

After Replacement

Contact [EMAIL REDACTED] or [EMAIL REDACTED] for support.
Complete Guide

📊 Key Data Points

JavaScript regex engine

Uses the browser native JavaScript regex engine — exactly the same engine your Node.js or browser code uses

Named capture groups

(?<name>...) syntax extracts named fields from matches — shown in the results panel

All JS flags

g i m s u d flags — toggle each to see how it affects matching

Regex Tester — Live Regular Expression Tester -- Complete USA Guide 2026

Writing a regular expression from memory and hoping it works on edge cases in production is a common source of bugs. This live regex tester runs your pattern against your test string in real time, highlighting every match as you type — the JavaScript engine, no intermediary, no server round-trip.

Runs entirely in your browser.

**Long-tail searches answered here:** regex tester online free with live highlighting, test regular expression browser tool no install, regex pattern tester javascript online.

For string operations, pair with String Inspector and Diff Checker.

🔬 How This Calculator Works

Uses new RegExp(pattern, flags) to compile your regex and String.prototype.matchAll() to find all matches. Match start/end positions are used to highlight spans in the test string in real time. Supports all JavaScript regex flags: g (global), i (case-insensitive), m (multiline), s (dotAll), u (Unicode), d (indices).

✅ What You Can Calculate

Live match highlighting

Every match is highlighted in the test string as you type the pattern. See exactly what the regex matches in real time — no run button.

Named capture groups

Named groups (?<name>...) display with their names in the match results. See the group values alongside the full match.

Flag toggles

Quick toggles for g, i, m, s, u, d flags. See immediately how case-insensitive or multiline mode changes what your pattern matches.

Error display

Syntax errors in the regex pattern are shown immediately with the error message — no need to run code to find out the pattern is invalid.

🎯 Real Scenarios & Use Cases

Validating input formats

Build and test patterns for validating email addresses, phone numbers, ZIP codes, ISO dates, or any custom input format before using them in production code.

Log file parsing

Test regex patterns for extracting fields from log lines. See all matches highlighted before using the pattern in awk, grep, or your application code.

URL pattern matching

Test route patterns for web frameworks. See which URLs match your pattern and which do not — before the routing logic is deployed.

String transformation preview

Build replacement patterns (using capture groups) and preview the transformation result before using String.replace() in your code.

💡 Pro Tips for Accurate Results

Start broad, then narrow. Begin with a simple pattern that over-matches, see the false positives highlighted, then add specificity to exclude them. Broad-to-narrow is much faster than trying to write a precise pattern from scratch.

Use named capture groups for readable code. (?<year>d{4})-(?<month>d{2})-(?<day>d{2}) is much clearer than (d{4})-(d{2})-(d{2}). Named groups also make the extraction code self-documenting.

Test edge cases explicitly. If you are validating email addresses, test: addresses with plus signs (user+tag@domain.com), subdomains (user@mail.example.com), and unusual TLDs. Real email addresses are more diverse than simple patterns assume.

The g flag is usually what you want. Without the global flag, the regex only finds the first match. Add the g flag when you need all matches.

🔗 Use These Together

🏁 Bottom Line

Regular expressions are the most powerful string processing tool in a developer toolkit — and the most error-prone. This tester shows exactly what your pattern matches before you commit it to code. For string analysis: String Inspector.

What regex flags does this tool support?

Five standard JavaScript flags: g (global — find all matches, not just the first), i (case insensitive — abc matches ABC), m (multiline — ^ and $ match line start/end), s (dotAll — makes . match newlines), u (unicode — proper Unicode support for emoji and international characters). Toggle flags with the buttons above the test string. Combining gi is the most common combination for case-insensitive find-all operations.

What is the difference between a capture group and a non-capturing group?

A capture group (pattern) stores the matched text for reference in replacements or code extraction. A non-capturing group (?:pattern) groups for quantifier application without storing — faster and cleaner when you do not need the value. A named capture group (?<name>pattern) gives the group a label accessible as match.groups.name. Use non-capturing groups for grouping with | alternation: (?:cat|dog)s matches cats or dogs. Use capture groups when extracting the matched content.

Why does my regex match too much — how do I make it less greedy?

Quantifiers *, +, and {n,} are greedy by default — they match as many characters as possible. On <b>Hello</b>, the pattern <.*> greedily matches the entire string from first < to last >. Adding ? makes it lazy: <.*?> matches only <b>, then </b> separately. Use lazy quantifiers when extracting content between delimiters like HTML tags, quoted strings, or parentheses where you want the shortest possible match.

How do I write a regex to match an email address?

A practical pattern handling most real-world addresses: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$. This matches the local part, the @ symbol, the domain, a literal dot, and a TLD of 2+ letters. True RFC 5321 email validation via regex is extremely complex — most applications use this simplified pattern or validate by sending a confirmation email. Paste it into the tester above to verify against your sample addresses.

What is the difference between ^ and $ with and without the multiline flag?

Without the m flag, ^ matches only the start of the entire string and $ matches only the end. With m enabled, ^ matches the start of each line (after a newline) and $ matches the end of each line (before a newline). This matters when matching patterns at the beginning of each line in a multiline input — for example, ^\s+ with flag gm finds leading whitespace on every line.

How do lookaheads and lookbehinds work?

A lookahead (?=pattern) asserts that what follows matches pattern without consuming those characters. \d+(?= dollars) matches a number only if followed by ' dollars', but the matched text is just the number. Negative lookahead (?!pattern) matches only if what follows does NOT match. Lookbehinds check what precedes: (?<=\$)\d+ matches numbers preceded by a dollar sign. Use them to assert context without including it in the match.

What tools pair well with the Regex Tester?

The Text Case Converter handles camelCase and snake_case transformations that often involve regex. The Duplicate Remover uses regex to identify repeated lines. The Diff Checker verifies that a regex-based replacement produced the expected result by comparing before and after. The Word Counter is useful after validating input format with regex. All are in the Dev Tools Text section.