Boneyard Tools

Regex Tester and Match Highlighter

Type a regular expression and some text to see every match highlighted instantly, with numbered and named capture groups. Toggle flags and try a replacement, all in your browser.

How to test a regular expression

  1. Enter your pattern and pick flags like g for all matches or i to ignore case.
  2. Paste the text you want to search into the test box.
  3. Read the highlighted matches and capture groups, or add a replacement to preview the output.

Examples

Find all numbers

Pattern /\d+/g on "a1b22c333"
3 matches: 1, 22, 333

Capture groups

Pattern /(\w)(\d)/g on "a1b2"
Match a1 with groups a and 1; match b2 with groups b and 2

Frequently asked questions

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

g finds every match instead of just the first. i ignores case. m makes ^ and $ match at the start and end of each line. s lets the dot match newline characters too.

How do capture groups work?

Parentheses create a capture group. Each match lists its numbered groups in order, and if you use named groups like (?<year>\d{4}) the captured name and value are shown as well.

Why is one of my matches empty?

Patterns that can match nothing, such as a* or (b)?, produce zero-length matches at positions where they apply. That is expected. The tester advances past them so it never gets stuck.

Which regex dialect does this use?

It uses the JavaScript RegExp engine built into your browser. Most features carry over from other languages, but lookbehind, Unicode property escapes and some syntax follow the ECMAScript rules.

Do I include the slashes in the pattern?

No. Type only the pattern source, for example \d+ rather than /\d+/g, and choose the flags separately with the checkboxes.

Is my text and pattern private?

Yes. Everything runs locally in your browser and nothing is uploaded to a server.

Related tools