ad
Regex Tester
Test regex patterns with live highlighting and match details.
//gi
What are Regular Expressions?
Regular expressions (regex or regexp) are patterns used to match character combinations in strings. They are a powerful tool for searching, validating, extracting, and replacing text. Regex is supported in virtually every programming language, text editor, and command-line tool.
A regex pattern consists of literal characters and special metacharacters. For example, \d{3}-\d{4} matches phone number patterns like "555-1234".
Quick Regex Reference
.— Any character (except newline)\d— Any digit (0-9)\w— Any word character (letter, digit, underscore)\s— Any whitespace character^and$— Start and end of string*,+,?— Zero or more, one or more, zero or one[abc]— Character class (matches a, b, or c)(group)— Capturing groupa|b— Alternation (a or b)
Common Regex Patterns
- Email —
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL —
https?://[^\s/$.?#].[^\s]* - IP Address —
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} - Date (YYYY-MM-DD) —
\d{4}-\d{2}-\d{2}
Frequently Asked Questions
- What regex flavor does this tool use?
- This tool uses JavaScript regular expressions (ECMAScript standard). This is the same regex engine used in browsers, Node.js, and Deno. Some features from PCRE (Perl) like lookbehinds are supported in modern browsers.
- What do the regex flags mean?
- g (global) finds all matches instead of stopping at the first. i (case-insensitive) ignores letter case. m (multiline) makes ^ and $ match line starts/ends instead of string start/end. s (dotAll) makes . match newlines too.
- How do I match an email address?
- A basic pattern is [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. However, email validation via regex is notoriously complex — for production use, send a verification email instead.
- What is the difference between .* and .*? (greedy vs lazy)?
- .* is greedy — it matches as many characters as possible. .*? is lazy — it matches as few as possible. For example, matching <.*> on "<a><b>" captures the entire string, while <.*?> captures just "<a>".
- Is my test data sent to a server?
- No. The regex matching runs entirely in your browser. Your patterns and test strings never leave your device.
ad