0

I am using preg_match function to my program. The code is like this

if (!$this->config_allow_src_above_docroot 
 && !preg_match('^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/',
                realpath($this->config_document_root))), $AbsoluteFilename)) 

During run the program it shows a warning like this

Warning: preg_match() [function.preg-match]: No ending delimiter '^'

How to solve this?

Mat
  • 202,337
  • 40
  • 393
  • 406
  • possible duplicate of [How to solve Preg\_match warning?](http://stackoverflow.com/questions/21339492/how-to-solve-preg-match-warning) Why did you start a new question when there was already an answer in your previous question about the same statement? – Barmar Jan 25 '14 at 13:23

1 Answers1

0

Your regular expression should start from some symbol that does not appear in regex itself and end with the same symbol.

Something like this:

$result = preg_match('#^foo#', $haystack);

Your expression starts with '^', so it should end with same symbol. And it will not work as you expect, it's a separator.

More information and examples: http://php.net/manual/en/function.preg-match.php