// free tool - regex tester

Regex Tester for JavaScript regular expressions

Type a pattern and see every match highlighted as you go. Inspect capture groups, preview replacements, read a plain-English explanation of each token, or start from a library of common patterns.

  • Free - no sign-up
  • Runs in your browser
  • Groups + replace
  • Explains tokens

Test your regex

JavaScript flavor, the same engine as Chrome and Node.js. Matches update as you type, and nothing leaves your browser.

Flags
Regex generator helpers
matches Ready

          

    Match details

    Each match with its position and capture groups.

    Explain this regex

    A token-by-token reading of the pattern, generated by rules (no AI).

      Private by design. Your pattern and test text are processed in this page only. They are not uploaded, logged or stored on a server.

      Common regex patterns

      Click a pattern to load it with sample text, then adapt it. Each one is a practical starting point, with its limits noted.

      Past the pattern

      Regex fixes one line. The codebase needs more.

      These AI skills plug into Claude, ChatGPT or any AI chat. Use them to write tricky patterns from a description, or for the backend work around them.

      A regex tester that shows its work

      This free regex tester runs your regular expression against sample text as you type and highlights every match. Below the highlight you get a table of capture groups, a live replace preview and a plain-English explanation of each token, so you can see why a pattern matches, not just whether it does. The engine is the JavaScript one built into your browser, so results are the same as in Chrome, Node.js, Deno and TypeScript code.

      The tester also works as a simple regex generator: load one of the common patterns, build an "any of these words" pattern from a list, or escape a literal string so dots and brackets lose their special meaning. Your text never leaves the page, which matters when you test against logs, customer data or tokens.

      Regex cheat sheet

      Token Meaning
      . Any character except a line break (any at all with the s flag)
      \d \w \s Digit, word character (a-z, A-Z, 0-9, _), whitespace. Uppercase versions mean "not".
      [abc] [^abc] [a-z] One character from a set, not from a set, or from a range
      ^ $ Start and end of the text, or of each line with the m flag
      \b Word boundary: the edge between a word character and anything else
      * + ? {2,5} Zero or more, one or more, optional, between 2 and 5 times
      *? +? Lazy versions: match as little as possible
      (x) (?:x) (?<name>x) Capturing group, non-capturing group, named group
      a|b Either a or b
      (?=x) (?!x) (?<=x) (?<!x) Lookahead, negative lookahead, lookbehind, negative lookbehind
      \1 \k<name> Backreference: the same text a group matched earlier

      Flags in JavaScript regular expressions

      g finds all matches instead of stopping at the first. i ignores case. m makes ^ and $ work on every line. s lets . match line breaks. u turns on full Unicode support, including \p{L} for any letter in any language and correct handling of emoji. y (sticky) only matches at the current position, which is useful in tokenizers. d adds start and end indices for every group, and v is a stricter successor of u that allows set operations inside character classes.

      Groups and replacements

      Parentheses do two jobs: they group part of a pattern so a quantifier applies to all of it, and they capture the text for later use. In a replacement string, $1 inserts the first group, $<name> a named group, $& the whole match and $$ a literal dollar sign. For example, the pattern (\w+)@(\w+) with the replacement $2: $1 turns ada@home into home: ada. If you only need grouping, use (?:...): it is faster and keeps group numbers stable.

      JavaScript regex vs PCRE and Python

      Most syntax is shared, but a few differences cause surprises when you copy a pattern between languages:

      • JavaScript has no possessive quantifiers (a++) or atomic groups. PCRE (PHP, many editors) does.
      • Python names groups as (?P<name>...); JavaScript uses (?<name>...).
      • Inline flags such as (?i) at the start of a pattern work in Python and PCRE. JavaScript only recently added modifier groups like (?i:...), so prefer the flag buttons.
      • In JavaScript, $ without the m flag matches only at the very end; in Python $ also matches before a final line break.
      • Without the u flag, JavaScript treats an emoji as two characters.

      If you write SQL or spreadsheet formulas, the same ideas show up in REGEXP and REGEXMATCH. The SQL query builder and Excel formula generator help with those.

      Avoid catastrophic backtracking

      Some patterns take exponential time on text that almost matches. The classic example is (a+)+$ against a long run of a characters followed by a different one: the engine tries every way of splitting the run between the inner and outer quantifier. In production this can freeze a page or take down a server, a problem known as ReDoS. This tester runs your pattern in a background worker and stops it after two seconds, so you see a warning instead of a frozen tab. To fix a slow pattern, avoid nesting quantifiers over the same characters, make alternatives mutually exclusive, and anchor the pattern where you can.

      Tips for writing maintainable regex

      1. Start from real sample text, including lines that must NOT match.
      2. Anchor validation patterns with ^ and $, otherwise \d{5} also matches inside 123456.
      3. Prefer specific classes such as [^"]* over .*.
      4. Use named groups so the code that reads the result explains itself.
      5. Do not use regex to fully validate emails, URLs or HTML. Use it to find candidates, then check them properly.

      Turn your regex cases into unit tests with the test case generator, or browse more free AI generators and tools.

      FAQ

      Which regex flavor does this tester use?

      It uses the JavaScript (ECMAScript) engine built into your browser, so results match Chrome, Node.js, Deno and TypeScript. Most syntax is shared with PCRE and Python, but features such as possessive quantifiers or Python style named groups are not supported.

      Is my test text sent anywhere?

      No. The pattern and the text are processed inside this page. Nothing is uploaded, logged or stored on a server. Settings are remembered only in your own browser.

      Why does my regex only find the first match?

      Turn on the g (global) flag. Without it, JavaScript stops after the first match. If ^ and $ should work on every line, also turn on the m (multiline) flag.

      What happens if my pattern is too slow?

      The tester runs the pattern in a background worker and stops it after two seconds. This protects the page from catastrophic backtracking, which usually comes from nested quantifiers such as (a+)+.

      Is the regex generator powered by AI?

      No. The pattern library and helpers are rule based: they load tested patterns, escape literal text and combine a word list into one pattern. For patterns written from a plain description, see the AI Regex Generator skill.