正则表达式电子邮件-忽略前导和尾随空格? [英] Regex Email - Ignore leading and trailing spaces?

查看:73
本文介绍了正则表达式电子邮件-忽略前导和尾随空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用以下内容在ASP.NET中进行电子邮件验证:

We are using the following to do an email validation in ASP.NET:

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

如何修改它以忽略开头和结尾的空格?

How can this be modified to ignore leading and trailing spaces?

我们在代码中处理的实际修饰在回发时,但是如果用户由于复制和粘贴而经常有多余的空间,则验证器将触发为无效。

The actual trimming we handle in code on postback but the validator is triggering as being invalid if the user has an extra space often due to copying and paste.

推荐答案

您可以在模式前后放置 \s * ,它应该可以正常工作。

You can place \s* before and after your pattern and it should work properly.

这篇关于正则表达式电子邮件-忽略前导和尾随空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆