function AbstractUnicodeString::match
Overrides AbstractString::match
File
-
vendor/
symfony/ string/ AbstractUnicodeString.php, line 238
Class
- AbstractUnicodeString
- Represents a string of abstract Unicode characters.
Namespace
Symfony\Component\StringCode
public function match(string $regexp, int $flags = 0, int $offset = 0) : array {
$match = (\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags ? 'preg_match_all' : 'preg_match';
if ($this->ignoreCase) {
$regexp .= 'i';
}
set_error_handler(static fn($t, $m) => throw new InvalidArgumentException($m));
try {
if (false === $match($regexp . 'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
throw new RuntimeException('Matching failed with error: ' . preg_last_error_msg());
}
} finally {
restore_error_handler();
}
return $matches;
}