All free tools

Regex tester for JavaScript

Type a pattern and some test text. Matches are highlighted as you type, with every capture group listed, and you can preview a replace before using it in code.

Runs in your browser. Your pattern and text are not sent to or stored by EpiFive.

Flags
Mode

0 matches

How to use it

  1. Type the pattern without the surrounding slashes, for example \d{4}-\d{2}-\d{2} for dates.
  2. Tick the flags you need: g for all matches, i to ignore case, m for line-by-line anchors.
  3. Paste your test text and check the highlighted matches and the groups table.
  4. Switch to Replace preview to see the result of text.replace() with your replacement.

Cheat sheet

  • . any character except a line break (with s, including line breaks)
  • \d \w \s digit, word character, whitespace; capitals negate them: \D \W \S
  • [abc] [^abc] [a-z] one of, none of, a range
  • * + ? {2,5} 0 or more, 1 or more, optional, between 2 and 5; add ? to make them lazy
  • ^ $ \b start, end, word boundary
  • (…) (?:…) (?<name>…) capture, group without capturing, named capture
  • (?=…) (?!…) (?<=…) (?<!…) lookahead and lookbehind
  • a|b either a or b
  • JSON formatter: Format, validate and minify JSON, with the line and column of any error.
  • Cron expression generator: Build or explain a 5-field cron expression in plain English and see the next run times.
  • JWT decoder: Decode a JSON Web Token’s header and payload and read its expiry times. Decode only, no verification.
  • Base64 encode and decode: Encode or decode Base64 text (UTF-8 safe) and convert files to and from Base64.

Questions people ask

Which regex flavour does this use?

JavaScript (ECMAScript), exactly as your browser runs it, including named groups, lookbehind, Unicode property escapes with the u flag and match indices with the d flag. Most patterns work the same in Python, Java and .NET, but details such as lookbehind limits and named-group syntax differ.

Why do I get only one match?

Without the g (global) flag, JavaScript stops at the first match. Tick g to find every match in the text.

What does “stopped after 1 second” mean?

The pattern took too long, usually because of catastrophic backtracking: nested quantifiers such as (a+)+ or (.*)* can try an exponential number of paths when a match fails. The tester runs your pattern in a background worker and stops it so the page doesn’t freeze. Rewrite the pattern to be more specific.

How do I use groups in the replacement?

Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match, and $$ for a literal dollar sign.

Is my text sent anywhere?

No. Matching happens in your browser, in a Web Worker on your device. Nothing is sent to or stored by EpiFive.