Carbon Ads · 728×90
//gi
2 matches
Contact us at support@example.com or sales@corp.io.
Invalid: bob@@nope
Visual breakdown
[\w.+-]Character class — matches one of \w.+- — repeated one or more times@Matches the literal text "@"[\w-]Character class — matches one of \w- — repeated one or more times\.Matches the literal character "."[\w.]Character class — matches one of \w. — repeated 2 to times
Copy code
JavaScript
const re = /[\w.+-]+@[\w-]+\.[\w.]{2,}/gi;
const matches = text.match(re);Python
import re
pattern = re.compile(r"[\w.+-]+@[\w-]+\.[\w.]{2,}", re.IGNORECASE)
matches = pattern.findall(text)Go
re := regexp.MustCompile(`(?i)[\w.+-]+@[\w-]+\.[\w.]{2,}`)
matches := re.FindAllString(text, -1)