Regex Tester

    Test JavaScript regular expressions in your browser with live match highlighting, capture groups, match indexes, flags, and syntax error reporting.

    /
    /
    Results
    No matches found.

    Try adjusting your regex pattern or test string.

    Regex Cheatsheet
    .Any character except newline
    \wWord (A-Z, a-z, 0-9, _)
    \dDigit (0-9)
    \sWhitespace (space, tab, etc)
    [abc]Any of a, b, or c
    [^abc]Not a, b, or c
    *0 or more
    +1 or more
    ?0 or 1
    {3}Exactly 3
    {3,}3 or more
    {3,5}Between 3 and 5
    ^Start of string / line
    $End of string / line
    \bWord boundary
    (abc)Capture group
    (?:abc)Non-capturing group
    (?=abc)Positive lookahead
    (?!abc)Negative lookahead
    gGlobal match
    iCase-insensitive
    mMulti-line
    uUnicode
    sDot matches newline

    Test JavaScript regular expressions directly in your browser. Enter a pattern, choose flags, and paste sample text to see highlighted matches, match counts, index ranges, matched text, and numbered capture-group values update as you type.

    This page is a JavaScript RegExp tester, not a PCRE, PHP, Python, Ruby, or database regex tester. The active implementation calls the browser's RegExp constructor, so syntax errors, flag support, Unicode behavior, and matching rules follow the JavaScript engine in the visitor's browser. That makes it a practical scratchpad for front-end code, Node-style pattern ideas, validation snippets, log parsing, and text cleanup patterns that will later run in JavaScript.

    What This Regex Tester Actually Does

    The tool has three working inputs: a pattern field, a flags field, and a test-string textarea. The pattern field is shown between slash characters for readability, but you type only the pattern body. For example, to match email-like text with a capture group, the default field contains ([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}), not the surrounding /.../ delimiters.

    When the pattern is present, the component builds a new regular expression with new RegExp(pattern, flags || 'g'). If the flags field is blank, the tool uses g by default. With a global pattern, it loops through re.exec(testString) and records every match. Without the g flag, it reports only the first match returned by exec(). The visible result list shows the match number, the start and end index, the exact matched text, and any numbered capture groups returned by match.slice(1).

    The editor area also creates a highlight overlay. Matched spans are wrapped in a visible style, while the rest of the test string is escaped before insertion into the overlay. That escaping is important because sample text can contain angle brackets, HTML fragments, or code examples, and the highlighter should display them as text rather than render them as page markup.

    How To Use The Tool

    1. Type the regular expression pattern body in the first field, without slash delimiters.
    2. Enter JavaScript regex flags in the small flags field, such as g, gi, gm, u, or s. Leave it blank only if you want the tool's default global search.
    3. Paste or type realistic sample text into the test-string textarea.
    4. Watch the highlighted text and results panel update automatically as the pattern, flags, or sample text changes.
    5. Open the cheatsheet sections when you need a reminder for character classes, quantifiers, anchors, groups, lookaheads, or common flags.
    6. Review the match indexes and capture groups before moving the pattern into production code, validation rules, or another tool.

    Inputs, Outputs, And Settings

    Part What it accepts What to check
    Pattern The JavaScript regular expression pattern body, without leading and trailing slash delimiters. Escaping can feel different from code strings. If a pattern will later be placed in a JavaScript string, you may need additional backslashes there.
    Flags Flags accepted by the browser's RegExp constructor. The cheatsheet lists g, i, m, u, and s. Unsupported, repeated, or incompatible flags show the browser's syntax error. Support for newer flags depends on the browser.
    Test string Any pasted or typed sample text that the browser can hold comfortably in the textarea. Very large input or expensive patterns can slow the tab because matching runs on the page as you type.
    Results Match count, highlighted match spans, start and end indexes, matched text, and numbered capture groups. Named group names are not displayed as labels. Captured values appear positionally as group 1, group 2, and so on.

    The built-in cheatsheet is a quick reference, not a complete language specification. For the underlying JavaScript behavior, MDN's JavaScript regular expressions reference and RegExp constructor documentation are better sources when you need exact syntax and flag rules.

    Example: Match Email-Like Text

    The default example demonstrates the tool's main workflow. The pattern is:

    ([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})

    The flags field contains g, and the sample text is:

    Contact us at support@example.com or info@example.org for more information.

    With the global flag enabled, the tool finds two matches. The first match is support@example.com, starting at index 14 and ending at index 33. The second match is info@example.org, starting at index 37 and ending at index 53. Because the whole email-like pattern is inside one capture group, each result also shows group 1 with the same email-like text.

    If you remove the g flag and keep the same pattern and text, the tool reports only the first match. That is expected because the implementation calls exec() once for non-global patterns. If you add the i flag, the pattern becomes case-insensitive. If you add m, anchors such as ^ and $ can operate line by line rather than only against the whole textarea.

    JavaScript Regex Behavior To Remember

    Regular expressions are not fully portable between programming languages. A pattern that works in JavaScript may need changes before it works in PHP's PCRE functions, a database query, an Nginx rule, a grep command, or a form-validation library. This tool is most reliable when the target environment is JavaScript or when you only need an exploratory first pass.

    The global flag changes how matches are collected. MDN's documentation for RegExp.prototype.exec() explains that global regular expressions keep state through lastIndex while repeated calls find successive matches. The inspected implementation also includes a guard for zero-length matches: if a match starts at the current lastIndex, the code increments lastIndex before continuing. That prevents patterns such as anchors or optional groups from getting stuck at the same position forever during a global scan.

    Capture groups are shown by numeric position. A pattern such as (\w+)=(\d+) against items=42 displays the full match items=42, group 1 as items, and group 2 as 42. Non-capturing groups such as (?:abc) affect matching but do not add a numbered result. JavaScript supports named capture groups in modern browsers, but this interface does not print the names from the returned groups object.

    Limitations And Performance Caveats

    This tester does not include replace mode, split mode, export, download, benchmark timing, saved history, a regex flavor selector, or a server-side validation step. It also does not prove that a validation rule is safe for production. A pattern can match your sample and still fail on edge cases, unusual Unicode text, different line endings, escaped input, or data that is much longer than the example you pasted.

    Be careful with patterns that contain nested quantifiers, ambiguous alternation, or broad wildcards near repeated groups. Some regular expressions can cause catastrophic backtracking on particular inputs, commonly discussed as regular expression denial of service, or ReDoS. This page does not sandbox, time-limit, or statically analyze patterns for that risk. Because matching runs in the browser tab, a pathological pattern against a long test string may make the page sluggish until the browser finishes or the tab is stopped.

    The index ranges shown by the tool are JavaScript string indexes. For ordinary ASCII text, those indexes usually line up with visible character positions. For emoji, combining marks, and some non-BMP Unicode characters, what a person sees as one symbol may use more than one UTF-16 code unit. Use the u flag and the target platform's own tests when Unicode correctness matters.

    Privacy And Browser Processing

    The inspected regex matching logic runs in the active browser page with Alpine and JavaScript. The pattern, flags, and sample text are read from the visible fields, tested in the browser, and rendered back into the results panel. No file upload control, remote regex API, server-side matching endpoint, or database save operation was found in the Regex Tester component.

    That does not mean every trace disappears. The sample may remain in the tab until you close or edit it, browser form restoration may remember field contents in some situations, and normal site analytics or browser extensions can still observe page-level activity depending on the visitor's setup. Avoid pasting secrets, access tokens, private customer records, unpublished credentials, or sensitive logs into any web page unless you are comfortable with the browser and extension environment you are using.

    Troubleshooting

    Problem Likely cause What to try
    The tool shows a syntax error. The browser rejected the pattern or flags passed to new RegExp(). Check unclosed groups, stray brackets, repeated flags, invalid escapes, and features unsupported by your browser.
    Only one match appears. The flags field does not include g. Add g when you want the tool to collect all matches instead of the first match.
    Expected line-start or line-end matches are missing. The pattern uses ^ or $ without multiline behavior. Add m if anchors should apply to each line in the textarea.
    Capture groups look incomplete. Optional groups may not participate, or non-capturing groups do not appear as numbered groups. Review the group syntax and test with a shorter string where each group is easy to see.
    The page slows down. The input is large, or the pattern is expensive for the current text. Test on a smaller sample, simplify nested quantifiers, and avoid using the page as a benchmark for untrusted patterns.

    Related Tools

    Regex testing is often one step in a larger text or developer workflow. Use JSON Viewer when the sample text is structured JSON and you need to inspect it before writing a pattern. Use HTML Formatter or HTML Tags Stripper when the regex work begins with messy markup. Use Email Extractor when the goal is simply to collect email-like strings without writing a custom pattern. Use Cron Generator for another developer utility where syntax, examples, and validation matter before a rule goes into production. For encoded text cleanup, URL Decoder and Base64 to Text can make sample input easier to read before testing a pattern.

    Editorial Review

    • Built and maintained by: Digital Domain Kit.
    • Verified technical method: Browser-side Alpine/JavaScript calls new RegExp(pattern, flags || 'g'), loops through exec() for global matches, records indexes and numbered capture groups, escapes text before creating the highlight overlay, and displays browser syntax errors for invalid patterns or flags.
    • Last reviewed: September 15, 2026.
    • Report a problem: Use the contact page if the live behavior differs from this description.