Regex empty string or email

前端 未结 7 1160
情深已故
情深已故 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:28

    The answers above work ($ for empty), but I just tried this and it also works to just leave empty like so:

    /\A(INTENSE_EMAIL_REGEX|)\z/i
    

    Same thing in reverse order

    /\A(|INTENSE_EMAIL_REGEX)\z/i
    

提交回复
热议问题