Matching query string for redirect

0 views
Skip to first unread message

Jesse

unread,
Oct 6, 2009, 4:01:39 PM10/6/09
to Regex
Trying to write a redirect and need to use regular expressions...

From Url: "^~/test/test.aspx?CatID=1003"
To URL: "~/whatever.aspx"

The important components for the redirect are the directory "test" and
the number "1003"

Without the query string (?CatID=1003) everything works fine.

I tried ^~/Test/.*\b1003\b.*$ but that didn't get me anywhere...

little help?

Jesse

Accmailer

unread,
Oct 7, 2009, 4:04:40 AM10/7/09
to Regex
I guess the problem was due to the fact that forward slashes should be
escaped with backslashes.

This one works OK:

^\s*\S+\/test\/.*\?\w+\=1003\b\S*\s*$

As a precaution, optional spaces added at the start and at the end of
the input.
Reply all
Reply to author
Forward
0 new messages