Regex for validating multiple E-Mail-Addresses

后端 未结 10 1695
忘了有多久
忘了有多久 2020-12-01 00:32

I got a Regex that validates my mail-addresses like this:

([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]

10条回答
  •  醉酒成梦
    2020-12-01 00:57

    Old post - needed the same RegEx. The accepted answer did not work for me, however, this did.

    ^(|([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$
    

    Retrieved from this post, however, the accepted answer did not work either, but the Regex on the link WITHIN the post did.

    abc@abc.com - validates

    abc@abc.com;123@qwer.com - validates

    abc@abc.com; - does not validate

    empty string - validates

    If you want to validate against an empty string, then remove the | at the beginning of the regex

提交回复
热议问题