Page 1 of 1

preg_match error in Zend Studio for Eclipse

Posted: Mon Jun 29, 2009 9:47 am
by dhinge
Zend Studio for Eclipse is giving me this error:

Multiple annotations found at this line:
- bad-escape : Bad escape sequence: \/, did you
mean \\/?
- bad-escape : Bad escape sequence: \/, did you
mean \\/?

This is my code:

if(preg_match("/\/(.*)\/public/i", $this->_request->__get('REQUEST_URI'), $matches))

It works fine, and if I add another backslash, it still works fine. Why is it giving me this error?

Re: preg_match error in Zend Studio for Eclipse

Posted: Mon Jun 29, 2009 10:58 am
by prometheuzz
Syntactically, that regex pattern is fine, as you might have guessed yourself since all worked just fine.
In order to get rid of that error, you might try to use different delimiters so that the Zend framework perhaps will not complain:

Code: Select all

if(preg_match("#/(.*)/public#i", $this->_request->__get('REQUEST_URI'), $matches))
in which case you need not escape the slashes.

HTH.