不要使用以下字符:< > ( ) [ ] ; : , \ 在电子邮件验证模式中

Do not use the following characters: < > ( ) [ ] ; : , \ in email validation pattern

我在 angular 应用程序中使用 regx 电子邮件验证模式。根据要求,我不想要以下字符:< > ( ) [ ] ; : , \

我正在使用以下模式。

let emailPattern = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;

谁能帮我解决这个问题。

您可以尝试使用这个正则表达式:

/^(([^<>()\[\]\.,;:\s@"]+(\.[^<>()\[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

或参考以下问题及其答案:How to validate an email address in JavaScript