Regex Tester

Type a regular expression and some test text to see every match highlighted as you type. This regex tester uses your browser’s JavaScript engine, lists each match with its position, capture groups and named groups, previews replacements, and explains errors in plain words.

Write the pattern without the surrounding slashes.
Flags
Ready.
Highlighted matches
Match details
    Use $1, $2 for groups, $<name> for named groups, $& for the whole match. Without the g flag only the first match is replaced.
    
        

    Runs entirely in your browser. Nothing you enter is uploaded or stored.

    Rate this tool

    Be the first to rate this tool

    How to use the Regex Tester

    1. Type your pattern in the Regular expression box, without the surrounding slashes, or load a common pattern.
    2. Turn flags on or off: g to find every match, i to ignore case, m for multiline, s so the dot matches line breaks, u for Unicode and y for sticky matching.
    3. Paste the text you want to test. Matches are highlighted instantly and listed with their positions and groups.
    4. Optionally type a replacement to preview the result, then copy the regex or the replaced text.

    What this regex tester does

    A regular expression (regex) is a small pattern language for finding text: email addresses in a log, dates in a document, or every word that starts with a capital letter. This tester runs your pattern with the same JavaScript RegExp engine used by web browsers and Node.js, so what works here works in your code. Every match is highlighted in the test text, and the match list shows the matched text, where it starts and ends (zero-based character indices), each numbered capture group, and any named groups such as (?<year>\d{4}). Group positions are shown when your browser supports match indices.

    Regex flags explained

    • g (global): find all matches. Without it, only the first match is found and replaced.
    • i (ignore case): cat also matches “Cat” and “CAT”.
    • m (multiline): ^ and $ match at the start and end of every line, not just the whole text.
    • s (dotAll): the dot . also matches line breaks.
    • u (unicode): treats emoji and other characters outside the basic range as single characters and enables \p{…} property escapes, such as \p{L} for any letter.
    • y (sticky): each match must start exactly where the previous one ended, which is useful for tokenizers.

    Quick regex cheat sheet

    \d digit, \w letter, digit or underscore, \s whitespace, . any character, [abc] one of a, b or c, [^abc] anything else, * zero or more, + one or more, ? optional, {2,4} two to four times, ^ and $ start and end, \b word boundary, (…) capture group, (?:…) non-capturing group, a|b either a or b, and (?=…) lookahead. Add ? after a quantifier, like .*?, to make it lazy so it matches as little as possible.

    Safe testing: errors, empty matches and slow patterns

    If a pattern is invalid, such as an unclosed bracket, the tester shows the browser’s error message instead of failing silently. Patterns that can match empty text, like a*, are handled by stepping forward one character after each empty match, so the tester never gets stuck. Results are capped at the first 1,000 matches to keep the page fast. Some patterns with nested quantifiers, like (a+)+b, can take an extremely long time on certain text; this is called catastrophic backtracking. The tester runs matching in a background worker and stops it after a short time limit, then tells you the pattern is too slow, which is a sign it needs rewriting before you ship it. Your pattern and text never leave your browser. To tidy JSON you extract, use the JSON formatter, or pull addresses out of text quickly with the email extractor.

    Examples

    • \b\d{5}(?:-\d{4})?\b on “Ship to 90210 or 10001-1234” → 2 matches: 90210, 10001-1234
    • (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2}) with replace $<m>/$<d>/$<y> → “2025-07-04” becomes “07/04/2025”
    • ^\w+ with flags g and m → the first word of every line
    • colou?r with flag i → matches color, Colour and COLOR

    Regex Tester FAQ

    Which regex flavor does this tester use?

    It uses the JavaScript (ECMAScript) regex engine built into your browser, the same one used by Chrome, Firefox, Safari, Edge and Node.js. Syntax from other flavors, such as possessive quantifiers or inline modifiers like (?i), may not be supported.

    Why does my pattern only find one match?

    Turn on the g (global) flag. Without it, JavaScript stops after the first match, and replace only changes the first occurrence.

    How do I use named groups in a replacement?

    Name the group with (?<name>…) and refer to it as $<name> in the replacement. Numbered groups are $1, $2 and so on, and $& inserts the whole match.

    What does “pattern took too long” mean?

    The regex hit catastrophic backtracking on your text, usually from nested quantifiers like (a+)+ or (.*)*. Make the pattern more specific, for example by removing the nesting, so it fails fast.

    Do I need to escape slashes?

    No. Type the pattern without the surrounding slashes; a forward slash inside the pattern does not need escaping here. In JavaScript code written as a /literal/, escape it as \/.

    Related tools

    All Developer Tools
    JSON Formatter & ValidatorBeautify, minify and validate JSON with clear error messages.Base64 Encode / DecodeEncode or decode Base64 for text and files, UTF-8 safe.Compare Two ListsFind differences, common items, and unique entries between two text lists.Cron Expression GeneratorBuild cron schedules with simple menus, or paste any cron expression to explain it in plain English and see the next 5 run times.Diff CheckerCompare two texts and see every added, removed and changed line, with word or character highlights, side by side or unified.HEX to RGB ConverterConvert HEX color codes to RGB, RGBA and HSL and back, with a live swatch, color picker, alpha control and copy-ready CSS.JSON to CSVConvert a JSON array to CSV with nested objects flattened into dot-named columns, comma, semicolon or tab delimiters and a live preview.JSON to ExcelConvert a JSON array to a real Excel .xlsx spreadsheet or CSV, with nested objects flattened into dot-named columns and a live preview.PX to REM ConverterConvert pixels (px) to rem and rem to px with custom root font size and CSS table.Unix Timestamp ConverterSee the current Unix epoch time live, convert timestamps in seconds, milliseconds or microseconds to dates, and dates back to timestamps.URL Decode & EncodeDecode or encode URLs and query strings (percent-encoding), with + as space option and a query parameter table.SRT to VTT ConverterConvert SRT subtitles to WebVTT (.vtt) or VTT to SRT with optional time shifting.Circle CropCrop any photo into a circle with a transparent background, an optional border and an exact output size.