I am currently learning regex and it is going fine. I now want to make a checker for email addresses. Basically its all good, I just found myself stuck at one small problem which I cannot seem to solve.
I saw that you can use "lookaround" options, but I cannot get them to work. What I want is that my group matches until the LAST @ sign. So for example
my-email@outlook.com would give me back my-email. my-@-email@outlook.com would give me back my-@-email.
Unfortunately my code would give me back my- only because I stop at the @ sign.
Below is my reg-ex and the email addresses I check on.
I hope that someone can explain to me how I can manage it to find everything, in other words email addresses that have multiple ampersands in them too.
([a-zA-z0-9._\-!#$%&'*+\/=?^_`{|}~"\(\)<>:,;]+|\"[a-zA-z0-9._\-!#$%&'*+\/=?^_`{|}~"\(\)<>:,; @]+\")@([a-zA-Z0-9\-]+|\[(.*)\])\.?([a-zA-Z0-9\-]+)?
the email adresses I check for (only 2 not working which are john.smith@worldwideweb.123com_org and "John."(),:;<>@[\].Doe"@.123radio_tv).
info@kamikaze.uk
alfred@live.nl
dubai@organon.it
karel.de.koning@hetnet.nl
decock@upc.nl
jiazhe_xu@sina.cn
xfunkblasterx@yahoomail.org
super-duper-email@hotmail.com
"John..Doe"@example.com
john.smith(comment)@example.com
(comment)john.smith@example.com
john.smith@worldwideweb.123com_org
"John."(),:;<>@[\].Doe"@.123radio_tv
"much.more unusual"@example.com
other.email-with-dash@example.com
disposable.style.email.with+symbol@example.com
"()<>[]:,;@\\"!#$%&'-/=?^_`{}| ~.a"@example.org
smith@[IPv6:2001:db8::1]
jsmith@[192.168.2.1]
Best regards
P.S. I use https://regex101.com/ to check the regex with the provided email addys
from Regex groups, untill last occurence within group
No comments:
Post a Comment