开发者

is it the right reqular expression

i have following regular expression but it's not working properly it takes only three values after @ sign but i want it to be any number length

"/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/"

this@开发者_如何学Pythonthi This is validated this@this It is not validating this expression

Can you please tell me what's the problem with the expression... Thanks


If you want your regex to match "any number length" then why are you using {2,4}?

I think a better example of the strings you're trying to match might give others a better idea of what you want, because based on your regex it is a bit confusing what you're looking for.


Try this:

^[a-zA-Z0-9_.-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,4}$

The main problem is that you didn't escape the dot: \.. In regular expression the dot matches everything (mostly), making your regex quite liberal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜