Level 102
Emails have ALOT of valid tlds. Not just com
Perhaps use php to check if the domain is valid afterwards?
Hi everybody, I'm using regex and match to grab all emails in an HTML string, however I'm getting false positives, how can I improve my regex (I'm not very good at it), I'd like to add something like "ends in .com" so I don't grab any false matches.
const emailRegex = /([\s]*)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*([ ]+|)@([ ]+|)([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,}))([\s]*)/ig;
let emailsInFacebook = bodyHTML.match(emailRegex);
This gives me an array with false positives like this one:
emails:
{
'0': '[email protected]',
'2': '[email protected]',
'3': '[email protected]'
}
Please or to participate in this conversation.