sindresorhus / email-regex

Regular expression for matching email addresses
MIT License
134 stars 17 forks source link

This string passes as an exact match: '<email@domain.com>' #2

Open smvilar opened 8 years ago

smvilar commented 8 years ago

emailRegex({exact:true}).test('<foo@bar.com>') // true :(

SamVerschueren commented 8 years ago

This library seems quite loose in terms of matching email patterns, is that correct? As I can see in the tests that !#$%&amp;*+/=?^{|}~@sindresorhus.com for example is an exact match. So if special characters like that are allowed but <foo@bar.com> isn't, what about the following situations

Just so I can expand the test cases and make sure the correct situations are covered.

gabooh commented 8 years ago

I have the same issue, many false positive are found.

vaticancameo commented 7 years ago

matching against 'text@example.com, some text' will return 'text@example.com,' with the comma

gtwilliams03 commented 6 years ago

I would like to use this module in my app - but I am finding that it returns some inconsistent results. Assuming this gist is a proper list of valid and invalid emails for testing: https://gist.github.com/cjaoude/fd9910626629b53c4d25

It does not seem to match correctly. The link above has 37 email addresses to test with - 17 are valid, 20 are invalid. Testing with this package results in 35 valid email addresses when I think it should only return 20.

It matches the following emails correctly:

It properly ignored these emails:

It errored on the following ones:

lxsmnsyc commented 5 years ago

I know that this is issue may be old but according to the RFC-822 on the Address Specification, the regex behaves correctly with the given test, that is because email addresses are not only limited to the format someName@someDomain.tld, but also someName<someName@someDomain.tld>, so this issue is not really an issue.

wmik commented 5 years ago

This is definitely an issue/bug.

emailRegex().test('f@il') // => true

Version 3.0.0

sindresorhus commented 5 years ago

@wmik Emails are not required to have a domain. You can find domain-less email on company intranets. We could add an option to require this however, as I agree it's not useful to allow domain-less emails for public services.

hmelenok commented 4 years ago

Please check, my regExp(https://regex101.com/r/YrpDBq/7) maybe it will help, only thing is left company emails

niftylettuce commented 4 years ago

I have published https://github.com/niftylettuce/email-regex-safe as an alternative to this package, with a lot of configurable options. PR's welcome.

babaralishah commented 2 years ago

Hi I am on Angular

And using the below regex:

'^[a-z0-9]+([._-]?[a-z0-9]+)+@[a-z0-9]+([._-]?[a-z0-9]+)+\\.[a-z]{2,3}$'

But its not fulfilling my requirement, my requirement is below:

saa5@me-d_d_u.co

please anyone tell me, why this regex is not working for my above mentioned case.

Regards Babar Ali Shah