regexp_quote() static public method

See also: http://ca.php.net/manual/en/function.regexp_quote.php
static public regexp_quote ( $string, $delimiter = '/' ) : string
$string string String to quote
$delimiter string Delimiter for regular expression
return string Quoted equivalent of $string
Esempio n. 1
0
 /**
  * Delete an email from the file buffer.
  * @param $key string Email key.
  * @return boolean True iff success.
  */
 function delete($key)
 {
     $matches = null;
     $quotedKey = PKPString::regexp_quote($key);
     preg_match("/<email_text[\\W]+key=\"{$quotedKey}\">/", $this->getContents(), $matches, PREG_OFFSET_CAPTURE);
     if (!isset($matches[0])) {
         return false;
     }
     $offset = $matches[0][1];
     preg_match("/<\\/email_text>[ \t]*[\r]?\n/", $this->getContents(), $matches, PREG_OFFSET_CAPTURE, $offset);
     if (!isset($matches[0])) {
         return false;
     }
     $closeOffset = $matches[0][1] + strlen($matches[0][0]);
     $newContents = substr($this->getContents(), 0, $offset);
     $newContents .= substr($this->getContents(), $closeOffset);
     $this->setContents($newContents);
     return true;
 }