Regex Tester

Text & Data Tools
Regex Tester
/ /
Results
Match Info
Highlighted Matches
Capture Groups
Match # Full Match Groups Index
Copy this code to embed: <iframe src="/calcs/calculators/text-data/regex-tester?embed=1.html" width="100%" height="500" frameborder="0" style="border:1px solid #e2e8f0;border-radius:8px;"></iframe>
Advertisement
How to Use This Calculator

How to Use the Regex Tester

The Regex Tester lets you write, test, and debug regular expressions against sample text in real time. Matches are highlighted instantly as you type the pattern, making it an indispensable tool for developers working with text processing, input validation, and data extraction.

Getting Started

Enter your regular expression in the pattern field and paste your test text in the input area. Matches are highlighted in the text as you type. The results panel shows each match with its position, captured groups, and the matched text. Flags (g, i, m, s) can be toggled with checkboxes.

Common Regex Patterns

Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} matches standard email formats.

Phone: \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} matches US phone numbers in various formats.

URL: https?://[\w\-]+(\.[\w\-]+)+[/\w\-.,@?^=%&:/~+#]* matches HTTP/HTTPS URLs.

IP Address: \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b matches IPv4 addresses.

Regex Flags Explained

g (global): Find all matches, not just the first. i (case-insensitive): Match regardless of letter case. m (multiline): ^ and $ match start/end of each line, not just the string. s (dotAll): Makes . match newline characters too.

Capture Groups

Parentheses create capture groups that extract specific parts of a match. In the pattern (\d{4})-(\d{2})-(\d{2}) applied to "2025-01-15", group 1 captures "2025", group 2 captures "01", and group 3 captures "15". Named groups use the syntax (?<year>\d{4}).

Frequently Asked Questions

Q: Why does my regex match too much (greedy matching)?

A: Quantifiers like * and + are greedy by default, matching as much as possible. Add a ? after them for lazy (non-greedy) matching. For example, <.*> matches an entire tag pair, while <.*?> matches just the first tag. Lazy matching stops at the earliest valid endpoint.

Q: Which regex flavor does this tester use?

A: This tester uses JavaScript (ECMAScript) regular expressions. Syntax is compatible with most languages but some features differ. Lookbehinds require modern browsers. PCRE features like recursive patterns and conditional groups are not available in JavaScript regex.

Q: How do I match special regex characters literally?

A: Escape special characters with a backslash. To match a literal period, use \. instead of . (which matches any character). Characters requiring escaping include: . * + ? ^ $ { } [ ] ( ) | \. Inside character classes [ ], most special characters are literal.

Advertisement
Advertisement