Regex Tester & Debugger

/ /
Flags: Global: find all matches
Enter a pattern and test string to see matches highlighted.

Match Results

0 matches
Enter a regex pattern and test string to see results.

Replace

Replace result will appear here...
Use $1, $2, etc. to reference capture groups. Use $& for the full match.

Common Patterns Quick Reference

Frequently Asked Questions

What is a regular expression (regex)?

A regular expression (regex) is a sequence of characters that defines a search pattern. It is used for string matching, searching, and text manipulation in programming languages, text editors, and command-line tools.

How do capture groups work in regex?

Capture groups are created by enclosing part of a regex pattern in parentheses, e.g. (\d+). When the regex matches, each group captures the text matched by that portion of the pattern. Groups are numbered starting at 1 and can be referenced in replacements as $1, $2, etc.

What are the most common regex flags?

The most common regex flags are: g (global) to find all matches instead of just the first, i (case-insensitive) to ignore letter casing, m (multiline) to make ^ and $ match start/end of each line, s (dotAll) to make the dot (.) match newline characters, and u (unicode) for full Unicode support.

What are some common regex patterns?

Common regex patterns include: email validation (e.g. [\w.-]+@[\w.-]+\.[a-zA-Z]{2,}), URL matching (https?://[^\s]+), phone numbers (\(\d{3}\)\s?\d{3}-\d{4}), IP addresses (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}), and dates (\d{4}-\d{2}-\d{2}).

How do I use regex replace?

Regex replace lets you search for a pattern and replace matches with a new string. You can reference capture groups in the replacement using $1, $2, etc. For example, the pattern (\w+)\s(\w+) with replacement $2, $1 would swap two words separated by a space.