Regex Tester

Free online regex tester with live match highlighting, capture group display, and replace mode. Test JavaScript regular expressions instantly in your browser. No signup required.

Advertisement
Advertisement

How to Use the Regex Tester

Enter your regular expression in the pattern bar at the top. The “/” delimiters and flag toggles work just like a JavaScript regex literal. Matches are highlighted live in the test string below as you type. Switch between the Matches, Groups, and Replace tabs to explore results in different ways. Use the pattern library to load common patterns and test strings with one click. Click Share to generate a permalink with your pattern and test string encoded in the URL.

About This Tool

A real-time regular expression tester that runs JavaScript’s native RegExp engine in your browser. Three result modes cover every use case: Match mode highlights all matches with position and line information, Groups mode displays numbered and named capture groups in a table, and Replace mode previews regex find-and-replace results live with highlighted replacements. A built-in pattern explanation breaks down your regex into human-readable tokens — turning this into a learning tool as well as a testing tool. Common patterns from a built-in library load with one click. Zero external libraries, zero server communication — your data never leaves your device. Related: JSON Formatter for formatting API responses, URL Encoder for encoding extracted data.

Quick Reference Table

TokenMeaning
.Any character (except newline without s flag)
\d \w \sDigit, word char, whitespace
\D \W \SNon-digit, non-word, non-whitespace
[abc]Character class: a, b, or c
[^abc]Negated class: not a, b, or c
(x)Capture group
(?:x)Non-capturing group
(?<name>x)Named capture group
x* x+ x?0+, 1+, or 0/1 occurrences
x{n,m}Between n and m occurrences
^ $Start / end of string (or line with m)
\bWord boundary
x|yx or y (alternation)

Frequently Asked Questions

Why does my regex match in JavaScript but not in Python?

Regex syntax varies between languages. This tool uses JavaScript’s RegExp engine specifically. Python uses different escaping conventions, and some engines support features JavaScript does not (atomic groups, PCRE extensions). Always test in your target language.

Why are my matches not overlapping?

JavaScript’s regex engine advances past each match before looking for the next one. Overlapping matches are not returned natively. Using a lookahead like (?=(...)) can work around this in some cases.

What is the difference between greedy and lazy matching?

Greedy quantifiers (*, +, ?) match as much text as possible. Lazy variants (*?, +?, ??) match as little as possible. For example, <.+> on ‘<b>hello</b>’ matches the entire string, while <.+?> matches ‘<b>’ and ‘</b>’ separately.

How do I match a literal dot or parenthesis?

Escape special characters with a backslash: \. matches a literal dot, \( and \) match literal parentheses. Special regex characters: . * + ? ^ $ { } [ ] | ( ) \

Is my data sent to a server?

No. All regex matching runs entirely in your browser using JavaScript’s native RegExp. Your patterns and test strings never leave your device.

Related Tools