Regex Tester

Type a pattern and a test string to see every match highlighted as you type.

Flags
Regex Flags

Live Results

Regex Syntax Cheat Sheet

Anchors
  • ^ Start of string (or line with m flag)
  • $ End of string (or line with m flag)
  • \b Word boundary
  • \B Non-word boundary
Character Classes
  • . Any character (except newline unless s flag)
  • \d Digit (0-9)
  • \D Non-digit
  • \w Word character (a-z, A-Z, 0-9, _)
  • \W Non-word character
  • \s Whitespace
  • \S Non-whitespace
  • [...] Any character inside brackets
  • [^...] Any character NOT inside brackets
Quantifiers
  • * 0 or more
  • + 1 or more
  • ? 0 or 1
  • {n} Exactly n times
  • {n,} At least n times
  • {n,m} Between n and m times
  • *? +? ?? Lazy (non-greedy) match
Groups and Lookaround
  • (...) Capturing group
  • (?:...) Non-capturing group
  • (?=...) Positive lookahead
  • (?!...) Negative lookahead
  • (?<=...) Positive lookbehind
  • (?<!...) Negative lookbehind

How to use it

  1. Enter a pattern between the slashes, or start from one of the presets.
  2. Open the Flags menu and tick the flags you need.
  3. Paste your text into the test string box. Matches are highlighted as you type.
  4. Open the Details tab to see each match with its position and capture groups.

The plain-English breakdown lists what each part of the pattern does, and Copy regex puts the full pattern with its flags on your clipboard.

Frequently Asked Questions

Which regex flavor does the tester use?
The JavaScript regular expression engine of your browser. Patterns that rely on features from other flavors, such as PCRE possessive quantifiers, may behave differently or be rejected.
What do the flags do?
g finds all matches instead of the first one, i ignores case, m lets ^ and $ match at line breaks, s lets the dot match newlines, u turns on full Unicode matching and y matches only at the position where the last match ended.
Is my text uploaded anywhere?
No. The pattern and the test string are processed in your browser and are not sent to a server.
Why is my pattern slow or freezing the page?
Nested quantifiers such as (a+)+ can cause catastrophic backtracking on certain inputs. Make the pattern more specific, for example by replacing .* with a narrower character class.
Are there ready-made patterns?
Yes. The preset buttons load example patterns with sample text for email addresses, domain names, URLs and IPv4 addresses. A syntax cheat sheet sits below the results.

TechBasket Tools

Published