Regex empty string or email

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

    I prefer /^\s+$|^$/gi to match empty and empty spaces.

    console.log("  ".match(/^\s+$|^$/gi));
    console.log("".match(/^\s+$|^$/gi));

提交回复
热议问题