Regex Tester
Write and test regular expressions with real-time matching, highlighting, and capture group extraction.
Regex Tester — Test Regular Expressions in Real-Time
This regex tester lets you write a regular expression and test it against sample text, seeing matches highlighted instantly as you type. It displays all matches, match positions, and the content of each capture group. The regex engine uses JavaScript's built-in RegExp, which is compatible with most modern programming languages for common patterns.
Regular Expression Flags
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 whole string. s (dotAll) — makes . match newline characters too. u (unicode) — enables full Unicode support. d (indices) — returns match index positions.
Common Regex Patterns — Quick Reference
Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} — URL: https?:\/\/[^\s]+ — Phone (India): [6-9]\d{9} — IP address: \b(?:\d{1,3}\.){3}\d{1,3}\b — Date (YYYY-MM-DD): \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) — HTML tag: <([a-z][a-z0-9]*)\b[^>]*> — Digits only: ^\d+$ — Letters only: ^[a-zA-Z]+$
Capture Groups vs Non-Capturing Groups
Capture groups (pattern) remember the matched text for back-references and capture display. Named capture groups (?<name>pattern) give groups a name for easier reference. Non-capturing groups (?:pattern) group without capturing — useful for applying quantifiers to a pattern without the overhead of capturing. This tester displays all capture group contents below each match.
Lookahead and Lookbehind
Positive lookahead (?=...) — match if followed by. Negative lookahead (?!...) — match if NOT followed by. Positive lookbehind (?<=...) — match if preceded by. Negative lookbehind (?<!...) — match if NOT preceded by. Example: \d+(?= dollars) matches numbers followed by " dollars".