TestersFreeNo uploadNo sign-up

Regex Tester

Test a regular expression against your text and see every match, group and replacement as you type.

Common patterns:
Test string
Result
Matches

    Explanation

      Cheat sheet

      .
      any character except newline
      \d \w \s
      digit, word character, whitespace
      \D \W \S
      not digit, not word, not whitespace
      [abc]
      a, b or c
      [^abc]
      not a, b or c
      [a-z]
      a letter from a to z
      ^ $
      start / end of text or line
      \b
      word boundary
      a* a+ a?
      0+, 1+, 0 or 1 times
      a{3} a{2,} a{2,5}
      exactly 3, 2 or more, 2 to 5
      a+?
      lazy: as few as possible
      (abc)
      capturing group
      (?<name>abc)
      named group
      (?:abc)
      non-capturing group
      a|b
      a or b
      (?=a) (?!a)
      followed / not followed by a
      (?<=a) (?<!a)
      preceded / not preceded by a
      \1 \k<name>
      back-reference to a group
      \p{L}
      any letter in any language (u flag)

      Runs in your browser. Your data is never sent to a server.

      How to use the Regex Tester

      1. Write the pattern

        Type your regular expression and switch flags such as g, i or m on and off. Or start from a ready-made pattern.

      2. Paste the test text

        Matches are highlighted in the text as you type, and each match is listed with its position and capture groups.

      3. Replace, explain, copy

        Try a replacement with $1 or $<name>, read what each token means, then copy the regex for JavaScript or Python.

      Why use this tool

      A regex test online is the fastest way to check a pattern before it goes into code: you see straight away whether it matches too much, too little or nothing at all. This regex tester uses the JavaScript (ECMAScript) engine built into your browser, the same one used by Node.js, TypeScript and every web page.

      Most everyday syntax is shared with Python, Java, PHP (PCRE) and .NET: character classes, quantifiers, anchors, groups and lookarounds work the same way. The differences are in the details, such as Python writing named groups as (?P<name>…) and JavaScript lacking possessive quantifiers, so the explanation panel and the code export note them for you.

      Frequently asked questions

      Which regex flavor does this tester use?

      JavaScript (ECMAScript 2024) as implemented in your browser. Patterns written for Python, Java or PCRE usually work unchanged unless they use engine-specific features such as possessive quantifiers, atomic groups or (?P<name>) group names.

      How do I test a regex for Python?

      Write the pattern here, then use Copy for Python. It wraps the pattern in a raw string and converts the flags, for example re.compile(r"\d+", re.IGNORECASE). Change (?<name>) to (?P<name>) for older Python versions.

      Why does my regex freeze or take forever?

      Nested or overlapping quantifiers such as (a+)+ or (.*)* can cause catastrophic backtracking, where the engine tries millions of paths. The tester runs your pattern in a separate thread and stops it after a second so you can fix it.

      How do I match a whole word only?

      Surround it with word boundaries: \bcat\b matches “cat” but not “category”. Add the i flag to ignore case.

      Is my text sent to a server?

      No. The pattern and the test string stay in your browser. A share link stores them in the address itself, after the # sign, which is never sent to our server.

      Are my files uploaded to a server?

      No. formatmath converts files with code that runs inside your browser. Your files are never uploaded, stored or seen by us.

      Is it free?

      Yes. There is no watermark and no daily limit. An account is optional and only keeps a history of your conversions.

      Latest guides and news

      We made this tooFree fee and profit calculators for Etsy, eBay and Amazon sellers.fee-math.com →