1
我正在爲asp.net服務器控件進行電子郵件驗證。在@符號之前允許「 - 」(連字符)用於電子郵件驗證
下面是樣品的郵件系統應該允許 -
[email protected]
[email protected]
[email protected]
[email protected]
誰能告訴我如何編寫上述電子郵件驗證正則表達式。
這裏是我的代碼工作正常進行簡單的電子郵件像[email protected]
等
var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/
var EmailmatchArray = UserEmail.match(emailPat);
if (EmailmatchArray == null) {
document.getElementById('<%=lblEmailErrorCtrl.ClientID%>').innerText = "Invalid email address";
return false;
}
快速[谷歌搜索](https://www.google.com/search?q=email+validation+regex&oq=email+validation+regex&aqs=chrome .. 69i57.263j0j7&sourceid = chrome&es_sm = 93&ie = UTF-8)「email驗證正則表達式」顯示了一些可能派上用場的事情,即[this question](http://stackoverflow.com/questions/201323/using-a-regular -expression到驗證-的電子郵件地址)。 –