public function testCheck() { $value = '/[a-z]/'; $regex = new Regex($value); $this->assertTrue($regex->check(new Text('asdf'))); $this->assertTrue($regex->check(new Text('as1df'))); }
public function __construct($raw) { $regex = new Regex('/^(?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\\1){4}[[:xdigit:]]{2}$/'); if (!$regex->check(new Text($raw))) { throw new InvalidArgumentException('Expected MAC address, but got [' . var_export($raw, true) . '] instead'); } $this->raw = $raw; }
/** * Checks if this Text object matches a regular expression * * @param Regex $regex The regex * * @return boolean True if this Text object matches the regular expression, false otherwise */ public function matches(Regex $regex) { return $regex->check($this); }