Regex Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roshawn

    #1

    Regex Help

    Hi,

    I'm doing url rewriting with the help of the Regex class. In my web.config file I have my rewrite rules specified. However,
    I have a lot of them as I have a dynamic storefront. Here's a sample:

    <Urls>
    <add key="/Shoes/-pg(\d+)\.aspx" value="/Shoes/Default.aspx?pg =$1"/>
    <add key="/Shoes/-t(\d+)\.aspx" value="/Shoes/Default.aspx?t= $1"/>
    <add key="/Shoes/-t(\d+)-pg(\d+)\.aspx" value="/Shoes/Default.aspx?t= $1&amp;pg=$2"/>
    <add key="/Shoes/-t(\d+)-s(\d+)\.aspx" value="/Shoes/Default.aspx?t= $1&amp;s=$2"/>
    <add key="/Shoes/-t(\d+)-s(\d+)-pg(\d+)\.aspx" value="/Shoes/Default.aspx?t= $1&amp;s=$2&amp ;pg=$3"/>
    ........ many more follow but are vastly different ........
    </Urls>

    Fortunately, these rules work like a charm. But I was wondering if I could somehow consolidate this sample into one or two
    rules with the use of regular expressions.

    It took me a while to get this working as I don't quite understand regular expressions correctly, so could someone out there
    help me?

    Thanks,
    Roshawn
Working...