I am looking to improve my regex skills for use in my Ruby programming.
I have come up with the matcher below for emails.
Can it be improved? Will it work for all email addresses?
Is the mailto: bit ok?
/(mailto:)*\w+@\w+.[A-z]+.[A-z]{2,4}/
It matches addresses like
bob@test.com
bob_smith@test.com
bob_smith@prefix.test.com
abc@xyz.co.uk
mailto:fred@test.com
short answer: NO. not ALL emails can be checked by regex. there’s a thread somewhere here on SO, where they explain this much better than i could if i attempted. I think the only way to check if email is really an email is to contact the mail server and enquire whether user account exists.
please, have a read here: https://stackoverflow.com/a/1373724/81520