Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

URL Rewrite - String parsing question

Last post 06-17-2009, 2:37 PM by tdurden500. 0 replies.
Sort Posts: Previous Next
  •  06-17-2009, 2:37 PM 54039

    URL Rewrite - String parsing question

    I'm fairly new to regular expressions, so I'm having a bit of trouble. I am using the URL Rewrite Module within IIS7/Win2K8.

    I am trying to come up with a regexp to rewrite part of the following "friendly" URL:

    /City-State/ (example: /Cleveland-OH/)

    as the following:

    doit.aspx?CITY=City&STATE=State (example: doit.aspx?CITY=Cleveland&State=OH)

    The CITY portion of the friendly URL will be of variable length, then a hyphen, then STATE portion (will always be the two-character state abbreviation).

    I thought about keying off the hyphen, but that would cause problems should there ever be a hyphenated city name. Instead, I was wondering if it is possible to parse the string for the last two characters?

    I suppose I could work the other way and just scan the string for the final hyphen (in the event that there are more than one).

    Any thoughts on the best way to handle this? 

View as RSS news feed in XML