Skip to content

Regex Tester

Pattern

/

/g

Flags

Test string

Results

Example
The pin code is 4892 and the backup is 7310.

About

Regular expressions (regex) are a pattern language for matching and extracting text. They are supported in virtually every programming language and are essential for tasks like input validation, search-and-replace, and parsing structured data from logs or documents.

How to use

  1. 1.

    Enter your regular expression in the Pattern field and toggle flags such as g (global), i (ignore case) and m (multiline)

  2. 2.

    Paste your text into the Test string panel - matches are highlighted in Results as you type; an invalid pattern is explained under the Pattern field

  3. 3.

    Open the Groups tab to see each match's capture groups in a table

  4. 4.

    Open the Replace tab and enter a replacement to preview a search-and-replace

Common uses

  • ▸

    Testing regex patterns for form validation (email, phone, postal code)

  • ▸

    Extracting structured data from log files or raw text

  • ▸

    Building search-and-replace patterns for scripts or editors

Frequently asked questions

Which regex flavor does this use?

This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript regex specification. Patterns work the same as in Node.js and browser JavaScript.


What do the flags do?

g finds every match instead of only the first (up to 1,000 are shown), i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines, u enables full Unicode matching, v (in browsers that support it) adds set operations inside character classes, and y only matches where the previous match ended - at the very start of the text for the first. Click a flag button to toggle it; u and v cannot be combined.


How do I preview a search-and-replace?

Open the Replace tab in Results and type a replacement in the "Replace with" field: the text below shows the matches replaced - every match with the g flag, otherwise only the first. Use $1 for a numbered group, $<name> for a named group, and $& for the whole match; an empty replacement deletes the matches.


What does "Pattern took too long" mean?

Some patterns, such as (a+)+$, backtrack catastrophically: on a near-match the engine tries an exponential number of ways before giving up. Matching runs in a background worker, so the page stays responsive, and anything slower than half a second is stopped. Rewrite nested quantifiers so each character can only be matched one way.


Is my text sent to a server?

All matching runs locally in your browser. No text or patterns are transmitted anywhere.