PeanutsMonkey
PeanutsMonkey

Reputation: 7105

What is wrong with this regular expression?

I have the regular expression below however it still seems to match when it should not

^article\/article_story\.aspx(\?id\=(?!1211)[0-9]{1,4})?$

So effectively if the ID equals to 1211 it should not match and the expression is passed however if it matches say ID 1212 it performs the necesarry task however it still seems to match when the ID is indeed 1211

Upvotes: 0

Views: 69

Answers (1)

manojlds
manojlds

Reputation: 301347

I don't see it matching 1211 : http://regexr.com?2uam7


And you are unnecessarily complicating it with a huge regex and the (!...). You can just match the id part ( groups ) and then see if it is not 1211. It is not necessary to do everything in regex.

Upvotes: 3

Related Questions