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

#IndexMatch
18asha@example.com
228support@buonnet.co.in

Explanation

  1. [A-Za-z0-9._%+-]one of: A–Z, a–z, 0–9, ".", "_", "%", "+", "-"
  2. +…repeated one or more times (greedy)
  3. @the literal text "@"
  4. [A-Za-z0-9.-]one of: A–Z, a–z, 0–9, ".", "-"
  5. +…repeated one or more times (greedy)
  6. .the literal text "."
  7. [A-Za-z]one of: A–Z, a–z
  8. {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);
}

Common patterns