Example #1
0
 /**
  * Strip regex delimiters and modifiers and returns the end delimiter and
  * the regex modifiers
  * 
  * @return array
  * 
  * @throws \REBuilder\Exception\InvalidDelimiter
  */
 protected function _stripDelimitersAndModifiers()
 {
     //Emit the regex delimiter token and strip it from the beginning of the
     //regex
     $delimiter = $this->_regex[0];
     $this->_emitToken(Token::TYPE_REGEX_START_DELIMITER, $delimiter);
     $this->_regex = substr($this->_regex, 1);
     //Get the right end delimiter and strip it from the end of the regex,
     //then get the modifiers
     $endDelimiter = Rules::getEndDelimiter($delimiter);
     $endDelimiterPos = strrpos($this->_regex, $endDelimiter);
     if ($endDelimiterPos === false) {
         throw new Exception\InvalidDelimiter("End delimiter '{$endDelimiter}' not found");
     }
     $modifiers = substr($this->_regex, $endDelimiterPos + 1);
     $this->_regex = substr($this->_regex, 0, $endDelimiterPos);
     $this->_modifiersStack->push($modifiers);
     return array($delimiter, $endDelimiter, $modifiers);
 }