Regex Tester
Write a regular expression and see matches highlighted live, with capture groups, replacements, a plain-English explanation and ready-to-paste code for JavaScript, Python and C#.
Pattern
//g
Highlighted matches
Contact asha@example.com or support@buonnet.co.in — not bob@invalid
Matches
| # | Index | Match |
|---|---|---|
| 1 | 8 | asha@example.com |
| 2 | 28 | support@buonnet.co.in |
Explanation
[A-Za-z0-9._%+-]one of: A–Z, a–z, 0–9, ".", "_", "%", "+", "-"+…repeated one or more times (greedy)@the literal text "@"[A-Za-z0-9.-]one of: A–Z, a–z, 0–9, ".", "-"+…repeated one or more times (greedy).the literal text "."[A-Za-z]one of: A–Z, a–z{2,}…repeated 2 or more times (greedy)
Code
const re = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
for (const m of text.matchAll(re)) {
console.log(m.index, m[0], m.groups);
}