@@ 356-365 (lines=10) @@ | ||
353 | * |
|
354 | * @return BooleanPrimitive |
|
355 | */ |
|
356 | public function match($regex, $flags = 0, $offset = 0) |
|
357 | { |
|
358 | $value = preg_match((string) $regex, $this->value, null, $flags, $offset); |
|
359 | ||
360 | if ($value === false) { |
|
361 | throw new RegexException('', preg_last_error()); |
|
362 | } |
|
363 | ||
364 | return new BooleanPrimitive((bool) $value); |
|
365 | } |
|
366 | ||
367 | /** |
|
368 | * Return a collection of the elements matching the regex |
|
@@ 378-394 (lines=17) @@ | ||
375 | * |
|
376 | * @return TypedCollection |
|
377 | */ |
|
378 | public function getMatches($regex, $flags = 0, $offset = 0) |
|
379 | { |
|
380 | $matches = []; |
|
381 | $value = preg_match( |
|
382 | (string) $regex, |
|
383 | $this->value, |
|
384 | $matches, |
|
385 | $flags, |
|
386 | $offset |
|
387 | ); |
|
388 | ||
389 | if ($value === false) { |
|
390 | throw new RegexException('', preg_last_error()); |
|
391 | } |
|
392 | ||
393 | return new TypedCollection(self::class, $matches); |
|
394 | } |
|
395 | ||
396 | /** |
|
397 | * Replace part of the string by using a regular expression |