简体   繁体   中英

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"?

Try something like this:

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

Or if lookarounds aren't available:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM