Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse & Extract : wrong regex for email #192

Open
simonaubertbd opened this issue Nov 15, 2024 · 1 comment
Open

Parse & Extract : wrong regex for email #192

simonaubertbd opened this issue Nov 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@simonaubertbd
Copy link

Hello,

I made a small test with a string that may contains email. Here the result :
image

As you can see, one of the results is not correct (..com with two points)

I think you should use this instead
(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"+"'"+"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"+"'"+")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

According to https://emailregex.com/, it's the RFC 5322 Official Standard.

(would be even better if you change the label to "Email - RFC 5322, it makes it street cred ;) )

Best regards,

Simon

@tgourdel
Copy link
Contributor

Thanks Simon, good catch, I'll try your suggestion!

@tgourdel tgourdel added the enhancement New feature or request label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants