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

must be a simple RegEx for ISAPI Rewrite 3

Last post 08-28-2008, 10:42 AM by ste1977. 2 replies.
Sort Posts: Previous Next
  •  08-26-2008, 9:55 PM 45676

    must be a simple RegEx for ISAPI Rewrite 3

    Hi all

    i have spent some much time trying to work this out..

    the problem

    I'm using ISAPI Rewrite 3 with i think is just like Apache url re writer. i;m trying to get 3 matches.

    page/fine_london.asp

    ^page/(\w+)_(\w+)\.asp       is matches

    $0 = page/fine_london.asp  AND $1 = fine  AND  $2 = london

    but i have a query like the one below where i need to match + - % and number for each match i can't work it out. so

    ^page/fine+edge-nail_london+%28west%28.asp 

    should match

    $0 = page/fine+edge-nail_london+%28west%28.asp   AND $1 = fine+edge-nail  AND  $2 = london+%28west%28

     

    pls help as this is driving me mad.

     thanx for looking.

  •  08-26-2008, 11:02 PM 45678 in reply to 45676

    Re: must be a simple RegEx for ISAPI Rewrite 3

    Try:

    ^page/([\w+-]+)_([\w+%]+)\.asp

    If you need other characters in the #1 or #2 match groups then add then into the character set definitions. Just a word of warning about the first character set definition: note that it has a hyphen in it - this character must be that last (or first) character in the class set or it will be interporeted as a character range operator, so if you add other characters into here, then make sure this is still the last character.

    Another approach is that if you know that the first part will always end on the underscore and the second part will always end in the period (and that both characters will always be present), then something like:

    ^page/([^_]+)_([^.]+)\.asp

    will also work.

    Susan

  •  08-28-2008, 10:42 AM 45743 in reply to 45676

    Re: must be a simple RegEx for ISAPI Rewrite 3

    thanks that's worked.... looks so easy when someone else does it. thanks again.
View as RSS news feed in XML