.*

Regex Tester

Test regular expressions live with match highlighting, capture groups, and all flags. JavaScript (ES2023) engine.

/ /g
ℹ️ Common Regex Patterns
📧 Email
🔗 URL
📞 Phone (10-digit)
📅 Date YYYY-MM-DD
🪪 PAN Number
📮 Pincode (6-digit)
🎨 Hex Color
🌐 IP Address

🔗 Related Tools

❓ Frequently Asked Questions

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to find, match, replace, or validate text. For example, the regex \d+ matches one or more digits, and [a-z]+ matches one or more lowercase letters.

What regex flags are available?

The main JavaScript regex flags are: g (global — find all matches, not just first), i (case-insensitive), m (multiline — ^ and $ match start/end of each line), s (dotAll — dot matches newlines too), and u (unicode).

What is the difference between .* and .+?

.* matches zero or more characters (including empty). .+ matches one or more characters (at least one is required). For example, .* matches an empty string but .+ does not.

What are regex capture groups?

Capture groups are parts of a regex enclosed in parentheses (). They capture the matched text for later use. For example, (\d{4})-(\d{2})-(\d{2}) matches a date and captures year, month, and day as separate groups. Named groups use the syntax (?<name>...).

What is the difference between greedy and lazy matching?

Greedy quantifiers (*, +, ?) match as much as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, <.+> greedily matches the entire string <b>bold</b>. <.+?> lazily matches just <b> then </b> separately.

What does the ^ and $ mean in regex?

^ matches the start of a string and $ matches the end. For example, ^hello$ matches only the exact string 'hello' and nothing else. Without anchors, the pattern can match anywhere within the string.

How do I test a regex for email validation?

A common email regex is: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ — paste this into the pattern field and test it against email addresses. The tool highlights matches in real time.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +, ?) match as much as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, <.+> matches the entire string 'text', while <.+?> matches only '' and '' separately.

How do I match a phone number with regex?

For Indian mobile numbers: ^[6-9]\d{9}$ matches 10-digit numbers starting with 6, 7, 8, or 9. For international format with +91: ^\+91[6-9]\d{9}$ — test both patterns in this regex tester.