Skip to main content

    Regex Tester

    Test and debug regular expressions in real time. See matches highlighted instantly.

    No signup. 100% private. Processed in your browser.

    Highlighted Matches (2)

    Contact us at hello@iforgeapps.com or support@example.co.uk for more info.

    Match Details

    #MatchIndex
    1hello@iforgeapps.com14
    2support@example.co.uk38

    Regular Expressions: The Developer's Swiss Army Knife

    Regular expressions (regex) are patterns that match text. They're the most powerful text-search tool in programming — and also the most feared. The syntax looks like line noise at first, but once you learn the building blocks, you can validate emails, extract data, find-and-replace across files, and parse logs in seconds.

    This tester uses JavaScript's built-in RegExp engine, which supports lookahead, lookbehind, named groups, and Unicode properties. Type your pattern, paste your test string, and see matches highlighted in real time — no server required.

    The famous joke about regex: "Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems." It's funny because it's sometimes true — but for text matching, nothing else comes close.

    Essential Regex Syntax

    PatternMeaningExample Match
    .Any character (except newline)a.c matches "abc", "a1c"
    \dAny digit (0-9)\d3 matches "123"
    \wWord character (letter, digit, _)\w+ matches "hello_123"
    \sWhitespace (space, tab, newline)\s+ matches " "
    ^Start of string/line^Hello matches "Hello world"
    $End of string/lineworld$ matches "hello world"
    *Zero or more of previousab*c matches "ac", "abc", "abbc"
    +One or more of previousab+c matches "abc", "abbc" (not "ac")
    ?Zero or one of previouscolou?r matches "color", "colour"
    {n,m}Between n and m repetitions\d{2,4} matches "12", "123", "1234"
    [abc]Character class (any of a, b, c)[aeiou] matches any vowel
    (group)Capture group(\d+)-(\d+) captures "12" and "34"

    Common Ready-to-Use Patterns

    What to MatchPatternNotes
    Email address[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Covers 99% of real emails
    UK phone number(?:\+44|0)\d{10}Matches 07xxx and +447xxx
    UK postcode[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}Case-insensitive with i flag
    URLhttps?://[\w.-]+(?:\.[\w]+)+[\w._~:/?#@!
    amp;'()*+,;=-]*
    HTTP and HTTPS
    Date (YYYY-MM-DD)\d{4}-\d{2}-\d{2}Doesn't validate actual dates
    Hex colour#[0-9a-fA-F]{3,6}Matches #fff and #ffffff
    IP address (v4)\b(?:\d{1,3}\.){3}\d{1,3}\bDoesn't validate range (0-255)

    Regex Flags Explained

    g — Global

    Find all matches, not just the first one. Essential for search-and-replace operations across entire strings.

    i — Case-insensitive

    Matches regardless of upper/lowercase. "hello" matches "Hello", "HELLO", "hElLo".

    m — Multiline

    Makes ^ and $ match start/end of each line, not just the entire string. Essential for line-by-line processing.

    s — DotAll

    Makes . match newline characters too. Without this, . matches everything except \n.

    u — Unicode

    Enables full Unicode matching. Required for correctly handling emojis, CJK characters, and \p Unicode properties.

    d — HasIndices

    Returns start/end indices for each capture group. Useful when you need to know the exact position of matches.

    Copy-Paste Regex Patterns

    What to MatchPatternExample Match
    UK postcode^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$SW1A 1AA
    UK mobile number^07\d{9}$07911123456
    Email (basic)^[^\s@]+@[^\s@]+\.[^\s@]+$user@example.com
    IPv4 address\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b192.168.1.1
    Date (DD/MM/YYYY)\d{2}/\d{2}/\d{4}15/04/2026
    Hex colour#[0-9A-Fa-f]{6}\b#FF5733

    These patterns work in most regex engines (JavaScript, Python, PHP). For production email validation, don't rely on regex alone — send a confirmation email. Regex can check format, but only delivery confirms the address exists.

    Related Tools

    How to use this tool

    1

    Enter a regex pattern

    2

    Add flags (g, i, m, etc.)

    3

    Paste your test string

    Common uses

    • Validating email addresses and phone numbers
    • Extracting data from log files and text
    • Find-and-replace with pattern matching
    • Parsing URLs and query parameters
    • Testing patterns before using them in code

    Share this tool

    Frequently Asked Questions