开发者

is it the right reqular expression

开发者 https://www.devze.com 2023-01-02 11:28 出处:网络
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

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

精彩评论

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