Penguin mascot
Developer Tools

Regex Tester

Regular expressions, minus the guesswork. Type a pattern, paste some test text, and the penguin highlights every match and lists your capture groups as you go.

JavaScript (ECMAScript) regex β€” no slashes needed, flags are the checkboxes

Type a pattern and some test text above.

How to use

  1. Type your pattern. Something like \d{3}-\d{4} for a phone-number fragment β€” no slashes needed.
  2. Toggle the flags. g finds all matches, i ignores case, m makes ^ $ work per line, s lets . match newlines.
  3. Paste test text. Matches highlight live as you type in either box.
  4. Inspect the groups. Every capture group shows up below with exactly what it caught.

Frequently asked questions

How do I test a regular expression online?

Type your pattern in the pattern box and paste sample text below β€” matches highlight instantly, with the count and capture groups listed underneath. Toggle the g, i, m, and s flags to change how matching behaves.

What do the regex flags g, i, m, and s mean?

g (global) finds every match instead of stopping at the first; i makes matching case-insensitive; m lets ^ and $ match at line starts and ends rather than just the string ends; s (dot-all) lets . match newlines too. Combine them freely.

Why is my regex not matching anything?

Usual suspects: a missing g flag (only the first match shows), unescaped special characters (use \. for a literal dot), or ^/$ anchors when you meant to search anywhere in the text. The tester shows a friendly error for invalid patterns β€” for valid-but-quiet ones, simplify the pattern and build it back up.

What are capture groups in regex?

Parentheses that β€œcapture” part of the match: (\d{3})-(\d{4}) grabs the area code as group 1 and the rest as group 2. Named groups like (?\d{4}) work too β€” everything captured shows up in the groups list below the matches.

Is this a JavaScript regex tester?

Yes β€” patterns run on the JavaScript (ECMAScript) regex engine, the same one in every browser and Node.js. Most syntax transfers to Python, Java, and other languages, but check their docs for lookbehind and flag differences.

Related tools

Keep the momentum going.