Dismiss Notice
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

htaccess regular expressions

Discussion in 'Programming' started by paulund, Sep 30, 2009.

  1. paulund

    paulund New Member Webmaster


    I am trying to generate a regular expression to match all words before a group of characters which is in-. The problem I am having is limiting this to the first in-.

    For example if I have a string:

    I can get these 2 variables by using the expression
    /([^\.]+)-in- ([^\.]+)(.*)

    But if variable2 has the characters in- the expressions to return the variable1 will also return characters in variable up to the in-.

    The expression found to get around this problem is ((?:(?!-in-).)*) which worked on my development server but when moved onto another server it returned a 500 internal server error because the htaccess is failing. When I checked the server logs I was getting the error:

    RewriteRule: cannot compile regular expression '^([^/]+)/([^/]+)/((?:(?!-in-).)*)(-in-)([^\\.]+) (.*)'\n.

    How would I rewrite the expression ((?:(?!-in-).)*) to return the 1st variable up to the characters -in-?


Featured Resources (View All)

Share This Page