예제 #1
0
 /**
  * WordMatcher constructor.
  *
  * @param array $words
  * @param array $options
  */
 public function __construct(array $words, array $options = [])
 {
     $options = array_merge(['escape' => true, 'atomic' => false, 'separated' => true, 'case-sensitivity' => false], $options);
     if ($options['escape']) {
         $words = array_map(function ($word) {
             return preg_quote($word, '/');
         }, $words);
     }
     $regex = implode('|', $words);
     if ($options['atomic']) {
         $regex = "(?>{$regex})";
     }
     $regex = "({$regex})";
     if ($options['separated']) {
         $regex = "\\b{$regex}\\b";
     }
     $regex = "/{$regex}/";
     if (!$options['case-sensitivity']) {
         $regex .= 'i';
     }
     parent::__construct($regex);
 }
 public function __construct()
 {
     parent::__construct('(\\w+::\\w+)');
 }
 public function __construct()
 {
     parent::__construct('"([^"]*)"');
 }
예제 #4
0
 public function __construct()
 {
     parent::__construct("-?[0-9]*\\.?[0-9]*");
 }
 public function testRegexMatcherShouldReturnFalseOnNoMatch()
 {
     $matcher = new RegexMatcher('[0-9]+');
     $this->assertFalse($matcher->matches('abc123', $value));
 }
 public function __construct()
 {
     parent::__construct("'([^']*)'");
 }
예제 #7
0
 public function __construct($regex, $constant)
 {
     parent::__construct($regex);
     $this->constant = $constant;
 }
예제 #8
0
 public function __construct()
 {
     parent::__construct('([\\w\\\\]+)');
 }