Live Matching · 20+ Presets · Named Groups

    Regex Validator & Tester

    Test, debug, and visualize regular expressions in real time — with live match highlighting, flag controls, named capture groups, and 20+ ready-to-use presets.

    Regex Validator

    Build, test & debug regular expressions in real-time

    Pattern
    //g
    Test String0 chars
    Match Preview
    Enter a regex pattern to see matches
    Match Details
    Match details will appear here
    Quick Reference

    Characters

    .Any character
    \dDigit (0–9)
    \wWord char
    \sWhitespace
    \bWord boundary

    Quantifiers

    *0 or more
    +1 or more
    ?0 or 1
    {n}Exactly n
    {n,m}Between n–m

    Anchors

    ^Start of string
    $End of string
    (?=...)Lookahead
    (?!...)Neg. lookahead
    (?<=...)Lookbehind

    Groups

    ()Capture group
    (?:)Non-capture
    (?<name>)Named group
    |Alternation
    [abc]Character class
    Developer Reference

    Master Regular Expressions — Patterns, Flags & Real Examples

    From email validation to log parsing to JWT extraction — regex is one of the most powerful tools in a developer's toolkit. This guide covers everything you need to write, test, and debug patterns confidently.

    Live Match Highlighting

    See every match highlighted in real time as you type your pattern — no run button needed.

    100% Client-Side

    Patterns and test strings stay in your browser. No server processing, no data collection.

    20+ Preset Patterns

    Instantly load common patterns for emails, URLs, phones, dates, IPs, logs, and more.

    Named Capture Groups

    Inspect named group values from (?<name>...) patterns directly in the results panel.

    Real-World Patterns

    6 ready-to-use regex patterns — copy & test above

    Select a pattern below, copy it, and paste into the Pattern field above to test it live.

    Pattern  /gi flags
    [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}
    Test String
    Contact us at support@example.com or sales@company.org for more info.

    💡 Matches standard email addresses. The gi flags make it global and case-insensitive.

    What is a Regular Expression?

    A regular expression (regex) is a pattern-matching language built into virtually every programming environment. It describes a set of strings using a compact syntax — letting you search, extract, validate, or replace text with a single expression instead of writing dozens of conditional checks.

    Regex powers input validation in forms, log analysis in DevOps, code search in IDEs, URL routing in web frameworks, and data extraction in ETL pipelines. Mastering regex makes you significantly faster at everyday engineering tasks.

    How the Regex Engine Works

    The regex engine reads your pattern and attempts to match it against the test string character by character. It uses backtracking — trying different paths through the pattern when a branch fails — to find all possible matches.

    Understanding backtracking helps you avoid catastrophic backtracking — a performance trap where nested quantifiers on overlapping patterns cause exponential matching time. This tool uses JavaScript's native RegExp engine, which is optimized for most real-world patterns.

    Regex Flags — Complete Reference

    Flags modify how the engine applies your pattern. You can combine multiple flags together.

    FlagNameEffectExample Use Case
    gGlobalFinds all matches instead of stopping at the firstExtract all emails from a document
    iCase-insensitiveMatches regardless of letter caseValidate usernames case-insensitively
    mMultiline^ and $ match start/end of each line, not the whole stringParse log files line by line
    sDotAllThe dot . matches newline characters tooMatch multi-line HTML blocks
    uUnicodeEnables full Unicode matching and escape sequencesMatch emoji, CJK, or non-Latin text
    dIndicesAdds start/end index of each match group (ES2022+)Precise cursor positioning in editors

    Regex Syntax Cheat Sheet

    Character Classes

    .Any char except newline
    \dDigit [0-9]
    \DNon-digit
    \wWord char [a-zA-Z0-9_]
    \WNon-word char
    \sWhitespace
    \SNon-whitespace
    [abc]Any of a, b, c
    [^abc]Not a, b, or c
    [a-z]Range a to z

    Quantifiers

    *0 or more (greedy)
    *?0 or more (lazy)
    +1 or more (greedy)
    ?0 or 1 (greedy)
    {n}Exactly n times
    {n,}n or more
    {n,m}Between n and m

    Anchors & Assertions

    ^Start of string/line
    $End of string/line
    \bWord boundary
    \BNon-word boundary
    (?=...)Positive lookahead
    (?!...)Negative lookahead
    (?<=...)Positive lookbehind
    (?<!...)Negative lookbehind

    Groups

    (abc)Capture group
    (?:abc)Non-capturing group
    (?<name>abc)Named capture group
    (?|abc|def)Branch reset
    \1Backreference to group 1
    \k<name>Named backreference

    Escaping & Special

    \Escape next character
    |Alternation (OR)
    (Open group
    [Open char class
    {Open quantifier
    \nNewline
    \tTab
    \rCarriage return

    Common Patterns

    ^\s+|\s+$Trim whitespace
    \s+ Multiple spaces
    \d{4}-\d{2}-\d{2}ISO date
    \b\w+\bWhole words
    (?i)wordCase-insensitive word
    ^.{8,}$Min 8 chars
    Common Use Cases
    • Form validation — emails, phone numbers, postcodes, URLs
    • Log analysis — extract errors, warnings, timestamps from log files
    • Code search & refactoring — find patterns across a codebase
    • Data extraction — parse CSV, JSON keys, or structured text
    • URL routing — match route parameters in Express, Next.js, Django
    • Security — detect injection patterns, SQL keywords, malicious input
    • Text replacement — rename keys, reformat dates, clean whitespace
    • Markdown/HTML parsing — extract links, headings, code blocks
    Tool Features
    • Live match highlighting — results update with every keystroke
    • 20+ preset patterns (email, URL, IP, date, phone, JWT, hex, ...)
    • All flags supported — g, i, m, s, u, d
    • Named capture group inspector — see group values by name
    • Match count + character statistics
    • Inline quick reference for tokens, quantifiers, anchors
    • Copy regex to clipboard in /pattern/flags format
    • 100% client-side — data never leaves your browser
    Named Capture Groups

    Using Named Capture Groups in JavaScript

    Named groups make your regex results readable. Instead of match[1], you access values by name with match.groups.name.

    named-groups.js
    const pattern = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g;
    const text = "Events: 2024-01-15, 2023-12-31";
    
    for (const match of text.matchAll(pattern)) {
      const { year, month, day } = match.groups;
      console.log(`Year: ${year}, Month: ${month}, Day: ${day}`);
    }
    // Year: 2024, Month: 01, Day: 15
    // Year: 2023, Month: 12, Day: 31

    💡 Paste (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) into the pattern field above and test it with "Events: 2024-01-15, 2023-12-31" to see group inspection live.

    Built-in Features of This Regex Tool

    Everything you need to write, test, and debug regex patterns in one free, browser-based workspace.

    Real-Time Matching

    Matches are highlighted the instant you type — no need to click run or submit. Flags update results immediately too.

    Pattern Presets Library

    Load from 20+ vetted patterns for emails, URLs, IP addresses, dates, phone numbers, hex colors, and more.

    Named Group Inspector

    Named capture groups from (?<name>...) patterns are displayed by name in the results panel for easy inspection.

    Syntax Error Detection

    Invalid regex patterns trigger an instant, clear error message so you can identify and fix syntax issues immediately.

    All JS Flags Supported

    Toggle g, i, m, s, u, and d flags independently from the UI — results update live with each flag change.

    Copy Regex String

    Export your pattern in /pattern/flags format with one click — ready to paste into any JavaScript, TypeScript, or JSON file.

    Frequently Asked Questions

    Common questions about regular expressions, flags, groups, and best practices.