Regex Tester

Developer Utility

Regex Tester

Test JavaScript regular expressions against sample text. Choose regex flags, see the match count, and highlight matched text as you edit.

//

Matches

0

Highlighted Result

Enter a JavaScript regular-expression pattern and sample text to see the number of matches and highlight the matching text. For example, use [A-Z]+ with the g flag to find uppercase runs.

The tester uses the browser's JavaScript regular-expression engine. It displays whole matches, not separate capture-group values, and a successful sample does not prove a pattern is correct for every input.

How to Use This Tool

  1. Enter a pattern without slash delimiters in the Regular Expression field.
  2. Enter the flags in the adjacent field, such as `g` for all matches or `gi` for case-insensitive matches.
  3. Type or paste sample text in Test Text.
  4. Review the match count, highlighted text, or the JavaScript error shown for an invalid pattern or flag.

Try a Pattern Against Example Text

To find digit runs, enter \d+, use the g flag, and test Order 12, item 305. To check an entire lowercase slug, try ^[a-z0-9-]+$ with the i flag removed if uppercase letters should fail. Include both expected matches and non-matches in your test text.

Flags and Capture Groups

The flags field accepts JavaScript regular-expression flags, including g (global), i (case-insensitive), and m (multiline). The tester enumerates all matches, adding g internally when it is omitted. Parentheses still define capture groups in a pattern, but this interface highlights full matches and does not list group values separately.

Check Edge Cases

Test empty values, line breaks, punctuation, and strings that almost match. Avoid testing untrusted or extremely long text with complex patterns: regular-expression evaluation runs in the browser's main thread and can make the page unresponsive.

Frequently Asked Questions

Which regex flavor does this tool use?

This tool uses the native JavaScript (ECMAScript) regular expression engine, making it perfect for frontend and Node.js development.

How do I use capture groups?

Wrap part of your pattern in parentheses `()` to define a capture group. This tester highlights the full match and does not display individual capture-group values.

What does the 'm' (multiline) flag do?

The multiline flag makes `^` and `$` match the start and end of each line within the text, rather than just the start and end of the entire string.

Related Developer Tools

These tools are commonly used alongside this one.