preg_match error in Zend Studio for Eclipse

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dhinge
Forum Newbie
Posts: 12
Joined: Mon Jan 08, 2007 1:56 pm

preg_match error in Zend Studio for Eclipse

Post 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?
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: preg_match error in Zend Studio for Eclipse

Post 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.
Post Reply