Murtaza Mandvi
Murtaza Mandvi

Reputation: 10988

IIS 7 URL rewrite regular expression

Using IIS7 URL rewrite module, I am trying to get the value of a specific query string parameter, and if it exists I need to get the value of that parameter.

Example URL :

test.aspx?F5REDIRECTION&SearchType=HeaderSearch&hiddendims=&Keyword=tshirt&nkw=1&vsp=2

I need to check if "Keyword" parameter exists and I need to get the value "t-shirt".

If I test run this pattern :

^.*F5REDIRECTION&SearchType=Header.*Keyword=(.*)$

the result is "tshirt&nkw=1&vsp=2"

How do I get only "tshirt"?

Upvotes: 1

Views: 618

Answers (1)

Justin Morgan
Justin Morgan

Reputation: 30695

Try something like this:

(?<=\?|&)Keyword=(.*?)(?=&|$)

Or if lookarounds aren't available:

(?:\?|&)Keyword=(.*?)(?:&|$)

Upvotes: 1

Related Questions