-1

I need a regex match for below set of urls containing ? (question mark)

http://mywebsite/page.aspx?MenuId=1
http://mywebsite/page.aspx?MenuId=2
http://mywebsite/page.aspx?MenuId=3
http://mywebsite/page.aspx?MenuId=4

pls advise

user3068811
  • 39
  • 1
  • 7

1 Answers1

0

You can do this via the following regular expression:

http\:\/\/mywebsite\/page\.aspx\?MenuId=\d+

That will match any url that looks like http://mywebsite/page.aspx?MenuId=109238091823 with any number entered in the ?MenuId= parameter being matched.

You can check out http://regex101.com for a good interactive IDE for regular expressions. It also gives you live feedback as you go.

Joeytje50
  • 18,636
  • 15
  • 63
  • 95
  • If your only going to be matching 0-9 its often better to use [0-9]+ not \d+ as \d can also match various other characters – Srb1313711 Jan 22 '14 at 11:56
  • According to http://regex101.com "\d match a digit [0-9]" so that would make those things exactly the same. What other characters do you say it matches? – Joeytje50 Jan 22 '14 at 12:15
  • http://stackoverflow.com/questions/6479423/does-d-in-regex-mean-a-digit There will rarely be a case when someone might enter another character that \d matches but just in case using [0-9] is generally better if only matching numbers. – Srb1313711 Jan 22 '14 at 12:36