0

i have this regex that i use with my website

^.*/([a-z0-9,-]+)/([a-z0-9,-]+)/$

My question is who i can use querystring with my regex,

/about-us/contact/?l=en -> page.aspx?id=12&l=en

where id=1 = /about-us/contact/

where l=en = /?l=en

EDIT:

^.*/([a-z0-9,-]+)/([a-z0-9,-]+)/(\?l=en)

i get error on this : \ i C#

Is there a way in regex to tell if ?x=x exist the regex is a match, but if ?x=x don't exist the regex for /about-us/contact/ is a match?

Thanks,

Zombo
  • 1
  • 62
  • 391
  • 407

2 Answers2

0

If you want to include a ? character in your search pattern, you just have to escape it with a backslash. So if you want to find 'l=en', you look for '\?l=en'

^.*/([a-z0-9,-]+)/([a-z0-9,-]+)/(\?l=en)
Zombo
  • 1
  • 62
  • 391
  • 407
0

Expression

[\?&](?<name>[^&=]+)=(?<value>[^&=]+)

Description Matches name/value pairs in HTTP Query Strings, placing name into group named "name" and value into group named "value"

Matches-->http://stackoverflow.com/?a=b&c=d

Non-Matches-->http://stackoverflow.com/

Author Rating: Kevin Spencer.

SoftwareARM
  • 1,115
  • 10
  • 5