views:

282

answers:

2

Hello,

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

Hope you understand, Thanks for help :)

A: 

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)
A: 
^.*/([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,

Frozzare
@Frozzare: This section of the page is reserved for actual answers. Please post comments as a direct comment, and make additions to your question if you like. But don't use this web site like a forum, because it isn't. ;-)
Tomalak