Regex excluding catches that ending with a dot

Regex excluding catches that ending with a dot



First of all, I don't need full e-mail address validation, my given task doesn't require it. I just want to upgrade my current regex code so that it won't match addresses ending with a dot.



My current code: [0-9A-Za-z.]+[@][0-9A-Za-z.]+


[0-9A-Za-z.]+[@][0-9A-Za-z.]+



It catches both "user@exampe.com", "user@example.com."


user@exampe.com


user@example.com



I'd like it to catch only from the string that ends without the dot. user@exampe.com


user@exampe.com



Example string:



dasd.fas@fsaf.dfas.dsa, zghs@gas.gsq, adg32.dsa12@cas, ksak@c.csa., gs32.basaa@scaa.upc.


dasd.fas@fsaf.dfas.dsa


zghs@gas.gsq


adg32.dsa12@cas



I'd like to catch the strings marked as code in the example.



Edit: I have only one line with multiple e-mail addresses separated with a , and a space after them.


,


space






End with [^.]$?

– CertainPerformance
Sep 9 '18 at 3:59


[^.]$






Try ^YOUR-REb$

– revo
Sep 9 '18 at 4:03


^YOUR-REb$






@ssieightynine, what is the character/sring between each email strings? tell us what is the whole input string is exactly.

– The Scientific Method
Sep 9 '18 at 6:40







Please specify a language or tool.

– revo
Sep 9 '18 at 8:20




4 Answers
4



You might add [0-9A-Za-z]after your regex to end with what you want to match in your character class without the dot followed by a positive lookahead (?=, |$) that asserts what follows is either a comma followed by a whitespace or the end of the string.


[0-9A-Za-z]


(?=, |$)



[0-9A-Za-z.]+@[0-9A-Za-z.]+[0-9A-Za-z](?=, |$)


[0-9A-Za-z.]+@[0-9A-Za-z.]+[0-9A-Za-z](?=, |$)



Regex Demo



([0-9A-z.]+@(?:.?[0-9A-z]+)+)(?=,|$)


([0-9A-z.]+@(?:.?[0-9A-z]+)+)(?=,|$)






Doesn't work if the last string doesn't end in a .

– Nick
Sep 9 '18 at 5:26


.






Fixed the problem

– Adam
Sep 9 '18 at 5:44



Just slightly modify your pattern: [0-9A-Za-z.]+[@](?:[a-zA-Z]|.(?=[a-zA-Z]))+.


[0-9A-Za-z.]+[@](?:[a-zA-Z]|.(?=[a-zA-Z]))+



It uses alternation after @ to match one or more: letters OR dot, if it's followed by another letter, thanks to positive lookahead: .(?=[a-zA-Z]).


@


.(?=[a-zA-Z])



Demo



Try this one:



just capture , , $ and group them in non-capturing group except end .


,


$


.


[0-9A-Za-z.]+[@][0-9A-Za-z.]+[0-9A-Za-z](?:(,|$))



demo here






Please read the whole question more carefully.

– sasieightynine
Sep 9 '18 at 6:09






@sasieightynine upated try it now

– The Scientific Method
Sep 9 '18 at 7:00



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

Node.js puppeteer - Use values from array in a loop to cycle through pages