Regex empty string or email

前端 未结 7 1167
情深已故
情深已故 2020-11-29 20:46

I found a lot of Regex email validation in SO but I did not find any that will accept an empty string. Is this possible through Regex only? Accepting either empty string or

相关标签:
7条回答
  • 2020-11-29 21:32

    Don't match an email with a regex. It's extremely ugly and long and complicated and your regex parser probably can't handle it anyway. Try to find a library routine for matching them. If you only want to solve the practical problem of matching an email address (that is, if you want wrong code that happens to (usually) work), use the regular-expressions.info link someone else submitted.

    As for the empty string, ^$ is mentioned by multiple people and will work fine.

    0 讨论(0)
提交回复
热议问题