toolo.dev

Regex Tester for JavaScript

Test regex online with live match highlighting, capture and named groups, and a find-and-replace preview. Uses JavaScript's RegExp engine with all eight flags.

g - Global search (find all matches)

i - Case-insensitive

m - Multiline mode (^ and $ match at each line)

s - Dot matches newline

u - Unicode support

y - Sticky search (match only at the start position)

d - Show the start and end index of each group

Use $1, $2 for numbered groups, $<name> for named groups and $& for the whole match. Without the g flag only the first match is replaced.

About the Regex Tester

Type a pattern and some text, and this regex tester highlights every match as you type, lists each capture group and previews a find-and-replace. It runs on your browser's own JavaScript RegExp engine, so a pattern that works here behaves the same way in JavaScript, TypeScript and Node.js.

Matching runs in a Web Worker on your device, and nothing you type is uploaded. A pattern that starts backtracking out of control is stopped after 1 second instead of freezing the tab.

  1. Type your pattern into Regular Expression without the slashes; they're drawn around the field, with the active flags after the closing one. Paste a full literal like /^\d+$/gm into the empty field and it's split into pattern and flags for you.
  2. Toggle flags with the buttons under Flags. g is on when the page opens. u and v switch each other off, and v only appears in browsers that support it.
  3. Paste the text to search into Test Text. Results highlights each match in alternating colors and the badge counts them. A zero-length match, like the ones a* finds between other letters, shows as a thin yellow bar.
  4. If the pattern can't compile, Invalid Regular Expression shows the engine's message, such as Unterminated group for a missing ). Pattern Too Slow means the run passed 1 second.
  5. Match Details lists every match with its Index and Groups: $1, $2 for numbered groups, <name> for named ones, and (no match) for a group that took no part. With d on, Index shows start and end offsets. Up to 1,000 matches are listed.
  6. Type a substitution into Replace With to see Replace Result. $1, $<name> and $& (the whole match) work as in String.prototype.replace. Need a starting point? Common Patterns loads Email, URL, Phone (US), Date (YYYY-MM-DD) or Strong Password with sample text.