邮件表达验证问题 [英] Email expression validation problem

查看:70
本文介绍了邮件表达验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我有两个表达式来验证电子邮件ID

#1^ [a-zA-Z0- 9_ \\ + - ] +(\\。[a-zA-Z0-9_ \\ + - ] +)* @ [a-zA-Z0-9-]

+(\\。[a-zA-Z0-9 - ] +)* \\。([a-zA-Z] {2,4})$



#2Regex.IsMatch(viewmodel.Email,@^ [\w-\。] + @([\\\ - ] + \。)+ [\ w - ] {2,4} $)





问题是#1验证表达式总是成功。但是#2验证表达式在某些情况下是失败的。



1.为什么表达式#2失败

2.哪个表达式(#1和#2)是最好用



请帮忙解决这个问题。



谢谢,

Shanmuga Raja



我的尝试:



我不知道为什么Regex.IsMatch(viewmodel.Email,@^ [\w-\。] + @([\w - ] + \。)+ [\w - ] {2,4} $) 失败。

Hi Friends,

I have two expression to validate the email ID
#1 "^[a-zA-Z0-9_\\+-]+(\\.[a-zA-Z0-9_\\+-]+)*@[a-zA-Z0-9-]
+(\\.[a-zA-Z0-9-]+)*\\.([a-zA-Z]{2,4})$"

#2 "Regex.IsMatch(viewmodel.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$)"


The Problem is #1 validation expression always successful. But #2 validation expression is fail in some case.

1. why expression #2 is fail
2. Which expression ( #1 and #2) is best to use

Please help in this issue.

Thanks,
Shanmuga Raja

What I have tried:

I dont Know why "Regex.IsMatch(viewmodel.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$)" gets fail.

推荐答案





#2Regex.IsMatch(viewmodel.Email,@^ [\w-\。] + @([\\\ - ] + \。)+ [\ w-] {2,4}
"

#2 "Regex.IsMatch(viewmodel.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}








问题是#1验证表达总是成功的。但是#2验证表达式在某些情况下是失败的。



1.为什么表达式#2失败

2.哪个表达式(#1和#2)最好使用



请帮忙解决这个问题。



谢谢,

Shanmuga Raja



我尝试过:



我不知道为什么Regex.IsMatch(viewmodel.Email,@^ [\w-\。] + @([\w - ] + \。)+ [\w - ] {2 ,4}
)"


The Problem is #1 validation expression always successful. But #2 validation expression is fail in some case.

1. why expression #2 is fail
2. Which expression ( #1 and #2) is best to use

Please help in this issue.

Thanks,
Shanmuga Raja

What I have tried:

I dont Know why "Regex.IsMatch(viewmodel.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}


)失败。


这篇关于邮件表达验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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