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

Problem with negative lookbehind in PHP PCRE Library.

  •  05-06-2008, 3:23 PM

    Problem with negative lookbehind in PHP PCRE Library.

    I have the following regex statement I'm trying to run in PHP.

     (?<!(end\s?zone|lower|upper)\s?)(view)

     Testing against the following string: (matches in bold)

    "The endzone view goes hi upper view and he goes view and then goes view and view and view!!!"
    Notice "upper view" and "endzone view" are not matched. (Thats what I want.)
     
    It works correctly in my regex testing program, however when I try to run it in PHP I get

    Warning: preg_match() [function.preg-match]: Compilation failed: lookbehind assertion is not fixed length at offset ...

    After doing some research I found out the PCRE library does not support varying length lookbehinds.
    I'm having a hard time trying to figure out how to rewrite the regex without using the lookbehind.  Can anyone help?
     

View Complete Thread