Exemplo n.º 1
0
 /**
  * @param string $expr
  */
 public function __construct($expr)
 {
     try {
         $this->value = Regex::create($expr);
     } catch (\InvalidArgumentException $e) {
         $this->value = new Glob($expr);
     }
 }
Exemplo n.º 2
0
 /**
  * Checks if string matches a regexp
  * @param string $regex Regexp to match the string with
  * @return boolean
  */
 public final function match($regex)
 {
     Regex::create($regex);
     return false !== $regex->match($this->value);
 }
Exemplo n.º 3
0
 public function testGetRegex()
 {
     $this->assertEquals('/a/m', Regex::create()->literal('a')->getRegex());
     $this->assertEquals('%a%m', Regex::create()->literal('a')->getRegex('%'));
     $this->assertEquals('/a\\//m', Regex::create()->literal('a')->literal('/')->getRegex());
     $this->assertEquals('/a/muS', Regex::create()->literal('a')->getUtf8OptimizedRegex());
 }