Esempio n. 1
0
 /**
  * Sets the character code. It can be 0, 1 or 2 digits that represents
  * the octal number that identifies the character
  * 
  * @param string $char Character to match
  * 
  * @return OctalChar
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setChar($char)
 {
     if (!preg_match("#^(?:0[0-7]{1,2}|[0-7]{2,3})\$#", $char)) {
         throw new \REBuilder\Exception\Generic("Invalid octal character '{$char}'");
     }
     return parent::setChar($char);
 }
Esempio n. 2
0
 /**
  * Sets the character to match. It can be any character
  * 
  * @param string $char Character to match
  * 
  * @return ControlChar
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setChar($char)
 {
     $char = "{$char}";
     if (strlen($char) !== 1) {
         throw new \REBuilder\Exception\Generic("Control character requires a single character");
     }
     return parent::setChar($char);
 }
Esempio n. 3
0
 /**
  * Sets the character code . It can be 0, 1 or 2 hexadecimal digits
  * that represent a character code
  * 
  * @param string $char Character to match
  * 
  * @return HexChar
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setChar($char)
 {
     if ($char !== "" && !\REBuilder\Parser\Rules::validateHexString($char)) {
         throw new \REBuilder\Exception\Generic("Invalid hexadecimal sequence '{$char}'");
     } elseif (strlen($char) > 2) {
         throw new \REBuilder\Exception\Generic("Hexadecimal character can match a maximum of 2 digits");
     }
     return parent::setChar($char);
 }