Regex Tester

Test JavaScript regular expressions live, see every match and group, and try replacements.

/
Matches highlighted

    
    
    

    

JavaScript literal:

Cheat sheet
.Any character except a new line
\d \w \sDigit, word character, whitespace (capitals mean "not")
[abc] [^abc] [a-z]One of, none of, a range
* + ? {2,5}0 or more, 1 or more, optional, between 2 and 5 times
*? +?Lazy versions: match as little as possible
^ $ \bStart, end, word boundary
(…) (?:…) (?<name>…)Capturing, non-capturing and named groups
a|bEither a or b
(?=…) (?!…) (?<=…) (?<!…)Lookahead and lookbehind

Regex Tester

Write a regular expression and see immediately what it matches in your test text: every match is highlighted and listed with its position and capture groups, including named groups. Switch flags on and off, try a replacement string with $1 or $<name> references, and look up syntax in the built-in cheat sheet. Patterns run in a background worker, so a runaway pattern cannot freeze the page.

How to use Regex Tester

  1. Type the pattern, without the surrounding slashes.
  2. Choose the flags: g for all matches, i to ignore case, m for multi-line anchors, s for dot-all, u for Unicode.
  3. Paste the test text and look at the highlighted matches and the table of groups.
  4. Optionally enter a replacement to preview the result.

When it comes in handy

  • Building patterns for form validation, log parsing or search and replace.
  • Debugging why a regex does not match.
  • Learning regular expressions.

Frequently asked questions

Which regex flavour is this?
JavaScript (ECMAScript), as used in browsers and Node.js. Most syntax is shared with PHP (PCRE), Python and Java, but some features, such as possessive quantifiers, differ.
What happens with catastrophic backtracking?
Matching stops after two seconds and the tool tells you the pattern took too long, instead of freezing your browser.

Choose which cookies SEOpeck may use. You can change this at any time from "Cookie settings" at the bottom of every page.