Skip to main content

    Regex Tester

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

    Free to use. Runs in your browser.

    Enter a regular expression and test string to see matches, capture groups, and replacements in real time. Uses JavaScript regular expressions and common flags (g, i, m, s, u, d).

    amp;'()*+,;=-]*">

    Highlighted Matches (2)

    Visit https://iforgeapps.com/tools/ or https://example.com/docs for more info.

    Match Details

    #MatchIndex
    1https://iforgeapps.com/tools/6
    2https://example.com/docs39

    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, search 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 [at] example dot 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

    What regex engine does this tool use?
    JavaScript's built-in RegExp engine, which supports lookahead, lookbehind (ES2018+), named groups, Unicode properties (\p{}), and all standard quantifiers. It matches what runs in every modern browser and Node.js.
    Is my data sent to a server?
    No. Everything runs locally in your browser. Your patterns and test strings never leave your device, the matching happens via JavaScript's RegExp object right on the page.
    What regex flags are available?
    g (global, all matches), i (case-insensitive), m (multiline, ^ and $ match line boundaries), s (dotAll, . matches newlines), u (Unicode, correct emoji/CJK handling), and d (hasIndices, returns match positions). Combine them freely: 'gim'.
    Why does my regex match nothing?
    Common causes: forgetting the global flag (g) so only the first match is found; escaping issues (use \\ for a literal backslash in the pattern input); the pattern is case-sensitive but your text has different casing (add the i flag).
    What's the difference between .* and .*? (greedy vs lazy)?
    .* is greedy, it matches as much as possible. .*? is lazy, it matches as little as possible. For HTML like <b>one</b><b>two</b>, the pattern <b>.*</b> matches everything from first <b> to last </b>, while <b>.*?</b> matches each tag pair separately.
    How do I match a literal dot or bracket?
    Escape special characters with a backslash: \\. for a literal dot, \\[ for a bracket, \\( for a parenthesis. Inside a character class [.] a dot is already literal. The characters that need escaping: . * + ? ^ $ { } [ ] ( ) | \\
    What's a capture group and how do I use it?
    Parentheses () create capture groups that extract parts of a match. In the pattern (\\d{4})-(\\d{2})-(\\d{2}), group 1 captures the year, group 2 the month, group 3 the day. Named groups use (?<year>\\d{4}) syntax for readability.
    Can I use lookahead and lookbehind?
    Yes. Positive lookahead (?=...) matches if followed by the pattern. Negative lookahead (?!...) matches if NOT followed. Positive lookbehind (?<=...) matches if preceded by. Negative lookbehind (?<!...) matches if NOT preceded. These don't consume characters.
    How do I write a regex for email validation?
    A practical pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}. This catches 99% of real emails. Perfect email validation via regex is technically impossible, the full RFC 5322 spec is absurdly complex. For production, validate format then send a confirmation email.
    Why is my regex slow on long strings?
    Catastrophic backtracking. Patterns like (a+)+ or (a|a)* cause exponential matching time on non-matching inputs. Fix: use atomic groups (not available in JS), possessive quantifiers, or rewrite to avoid nested quantifiers. The pattern .*.*$ on a long non-matching string is a classic culprit.
    What's the difference between ^ and \\A (start anchors)?
    In JavaScript, ^ matches the start of the string (or each line with the m flag). JS doesn't support \\A. In other languages (Python, Ruby, Java), \\A always matches the absolute start of the string regardless of multiline mode, while ^ changes behaviour with multiline.
    Can regex match across multiple lines?
    By default, . doesn't match newlines and ^ $ only match string boundaries. Add the s flag to make . match newlines. Add the m flag to make ^ $ match line boundaries. Use both 'ms' flags to match patterns that span multiple lines with line-aware anchors.

    Results are for general informational purposes only and should be checked before use. They are not professional advice. See our Disclaimer and Terms of Service.