SuperDevTools

Regex tester online

Flags

JavaScript syntax, run by your browser's own engine: the same pattern may behave slightly differently in Python, PHP or Java.

Highlighted matches



  
View

Pattern explained, token by token

TokenMeaning
Common patterns

Simple starting points, not perfect validation: check them against your own data.

Ready-to-copy code



  

Everything runs in your browser: neither the pattern nor the text is sent anywhere. The last state is kept on this device.

A regular expression tester that explains what it finds

A regular expression, or regex, describes a shape of text: "five digits", "a word typed twice", "a date written as YYYY-MM-DD". Developers use them to search log files, validate form fields or run a find-and-replace across a whole project.

Type your pattern in "Pattern", tick the "Flags" you need, then paste a "Test string". The "Highlighted matches" update as you type, in two alternating underlined colors so that two matches sitting side by side stay distinct. The table lists each match with its position (counted from 0), its value and its groups, both numbered and named.

The pattern uses JavaScript syntax and runs in your browser's own engine. Nothing is uploaded: all the work happens on your device.

How to use it

  1. Enter a pattern such as \d+ and tick "g: all matches".
  2. With the test string a1b22c333, the tool reports "3 matches": 1 at position 1, 22 at position 3 and 333 at position 6.
  3. Switch to "Replace" to preview a substitution, or to "Split" to cut the text at every match.
  4. Read "Pattern explained, token by token", then copy the ready-made code or the shareable link.

Regex cheat sheet

SyntaxMeaning
\d \w \sa digit; an unaccented letter, digit or _; a whitespace character
[a-z], [^0-9]one character from the set, one character outside it
* + ? {2,4}0 or more, 1 or more, optional, 2 to 4 times
^ $ \bstart, end, word boundary
( ) (?: ) (?<name> )capturing, non-capturing and named groups
(?= ) (?! ) (?<= ) (?<! )lookahead and lookbehind, positive or negative
g i m s u y dflags: global, ignore case, multiline, dot-all, Unicode, sticky, group indices

Worked examples

The pattern (?<year>\d{4})-(?<month>\d\d) run on 2026-03 gives group 1 "year" = 2026 and group 2 "month" = 03. In "Replace with", $<month>/$<year> turns it into 03/2026; $1 inserts group 1 and $& the whole match.

The lookbehind (?<=\$)\d+ finds 15 in "$15 or 20 USD", since only the first number follows a dollar sign. With the u flag, \p{L}+ matches "café" and "naïve" in one piece, while \w+ stops at the accented letters. In "Split" view, [,;]\s* cuts "apples, pears;kiwis" into three pieces.

The explanation also breaks down a US phone pattern such as ^\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4}$: start of the text, an optional parenthesis, three digits, an optional separator, three digits, another optional separator, four digits, end of the text.

Common pitfalls

  • Greedy versus lazy. On <b>bold</b>, <.+> grabs everything in one go, while <.+?> finds <b> and then </b>.
  • Escaping. A dot means "any character": for a literal dot, write \.. Inside a string in source code, backslashes often have to be doubled; the generated code handles that.
  • Catastrophic backtracking. (a+)+$ on thirty "a" followed by a "b" tries billions of ways to split the text. The tool runs each pattern separately and stops it after one second with the message "Pattern too expensive", so the page keeps responding.

Regex engines are close cousins, but some features (named groups, lookbehind, \p{…}) are written differently or missing depending on the language, so always test in your target environment too.

Tips

Try your pattern on varied samples, including those that must not match: a date such as 2026-02-30, a four-digit ZIP code, an address with no dot. Don't try to validate an email address perfectly with a regex: a simple pattern catches typos, and only a confirmation email proves the address exists.

FAQ

Why does my pattern work here but not in my program?

The tool uses the browser's JavaScript engine. Python, PHP and Java differ on a few details: use "Ready-to-copy code", which adapts named groups and escaping, and read any notes added as comments.

What does the g flag do?

Without it, the search stops at the first match and a replacement only changes that one. With it, every match is found and replaced.

How do I share a pattern with a teammate?

"Copy link" puts the pattern, the flags and the test string (up to 1,000 characters) after the # sign of the address. That part is never sent to the server.

What does "(not used)" mean for a group?

The group exists in the pattern but took no part in that match, for example the branch that was not taken in an alternation like (a)|(b).