Results 1 to 2 of 2

Thread: Regex match string1 but not string2 - help please

  1. #1
    Join Date
    Jun 2006
    Location
    UK
    Posts
    15

    Regex match string1 but not string2 - help please

    Its probably really easy, but I have not been able to crack this one.

    I need a regex for AWStats that will match in the URL /blog but not /feed. I can match every occurrence of /blog or every line that does not contain /feed, but not both together.

    e.g.
    /blog/category/uebgrsekbgisuebgr/erthsrth/4/ WILL match
    /blog/feed/atom will NOT match
    /blog/2007/05/13 WILL match
    /blog/feed will NOT match
    /blog WILL match

    So far I have:

    Code:
    ^/blog/([^feed])
    But that's not matching anything.

    I have been using Regulazy to build and test my regex, as well as testing within AWStats.


    Please could somebody help me with this expression.

    Thanks in advance

    Tim

  2. #2
    Join Date
    Jan 2003
    Location
    USA
    Posts
    1,712
    I'm not great at regex, so forgive me if this is buggy. It works with all the scenarios you gave though:

    Code:
    /blog/?([^(feed)]{4}).*
    Hope that at least gets you on the right track
    -Saj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •