Regex Tester

Trending 🔥

Test regular expressions with live highlighting

How to Use Regex Tester

  1. 1Enter your regular expression
  2. 2Select flags (g, i, m, s, u)
  3. 3Paste test text
  4. 4Matches are highlighted in real time

About Regex Tester

Regex Tester provides a real-time environment for writing, testing, and debugging regular expressions. Enter your pattern and test string, and all matches are highlighted instantly as you type — no need to run code or reload a page.

Capture groups are displayed separately so you can inspect exactly what each group matched. The tester uses the JavaScript native RegExp engine, which is the same engine used in Node.js and all major browsers.

Patterns that work here will work directly in your JavaScript or TypeScript code.

Key Features of Regex Tester

  • Real-time match highlighting as you type the pattern
  • Displays all matches and their start/end positions
  • Shows capture groups and named groups separately
  • Supports flags: g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode)
  • Match count displayed prominently
  • Works entirely in-browser using JavaScript RegExp
  • Pattern explanation sidebar to understand each part of the regex
  • Compatible with Node.js and all major JavaScript runtimes

Examples

Validate an email address format

Test a regex pattern that matches standard email address formats.

Input

Pattern: ^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$ | Test: user@example.com and invalid-email

Output

user@example.com — 1 match | invalid-email — 0 matches

Extract all URLs from a block of text

Use a global pattern to find all HTTP/HTTPS URLs in a text string.

Input

Pattern: https?://[^\s]+ (with g flag) | Test: text containing multiple URLs

Output

All URLs highlighted, each shown as a separate match

Common Use Cases

  • Testing and iterating on input validation patterns (email, phone, postal code)
  • Building log parsing patterns to extract structured data from log lines
  • Writing search-and-replace patterns for code editors and scripts
  • Learning regular expression syntax interactively with immediate feedback
  • Debugging regex patterns that behave differently than expected in code
  • Extracting specific fields from structured text like CSV rows or configuration lines

Troubleshooting

Pattern matches nothing but looks correct

Solution

Check that the global (g) flag is set if you expect multiple matches. Without the g flag, JavaScript finds only the first match.

Backslashes in the pattern are not working

Solution

In JavaScript regex literals, \d, \w, \s are valid. If pasting from a string literal that used double backslashes, remove the extra backslash.

Regex causes the browser to hang or become unresponsive

Solution

Catastrophic backtracking can occur with certain patterns — for example, nested quantifiers like (a+)+ on a non-matching input. Simplify the pattern or test with shorter strings.

Frequently Asked Questions

What regex engine is used?

The tool uses the JavaScript native RegExp engine, compatible with lookaheads, lookbehinds, named capture groups, and Unicode property escapes.

What flags are supported?

Global (g), case-insensitive (i), multiline (m), dotAll (s) to make . match newlines, and unicode (u) for full Unicode support.

How do I match a newline?

Use \n to match a newline character. Enable the dotAll (s) flag to make . match newlines as well.

What are capture groups?

Capture groups are portions of a regex pattern in parentheses. For example, (\d{4})-(\d{2})-(\d{2}) on "2023-11-14" captures "2023", "11", and "14".

What is the difference between a greedy and lazy quantifier?

Greedy quantifiers (+ , *) match as much as possible. Lazy quantifiers (+?, *?) match as little as possible.

Can I test patterns with Unicode characters?

Yes. Enable the unicode (u) flag to use Unicode property escapes like \p{Letter}.

Is my data sent to a server?

No. All regex matching is performed locally in your browser. Your patterns and test strings never leave your device.

Can I use this regex in other programming languages?

JavaScript RegExp is similar to but not identical to Python, Java, or PCRE. Basic features are broadly compatible; language-specific syntax needs adjustment.