Пример #1
0
 /**
  * Match regex in document
  * ```php
  *  $tels = $html->match('!([0-9]{4,6})!');
  * ```
  *
  * @param string $regex
  * @param integer|callable $i
  * @return StringCollection
  * @throws \Exception
  */
 public function match($regex, $i = 1)
 {
     $documentHtml = $this->html('.')->getFirst();
     if (is_int($i)) {
         $collection = RegexHelper::match($regex, $i, [$documentHtml]);
     } elseif (is_callable($i)) {
         $collection = RegexHelper::matchCallback($regex, $i, [$documentHtml]);
     } else {
         throw new \InvalidArgumentException('Invalid argument. Expect integer or callable');
     }
     return $collection;
 }
Пример #2
0
 /**
  * Match strings and return new collection
  *
  * @param string $regexp
  * @param int $index
  * @return StringCollection
  */
 public function match($regexp, $index = 1)
 {
     return RegexHelper::match($regexp, $index, $this->items);
 }