function ByteString::match
Overrides AbstractString::match
File
-
vendor/
symfony/ string/ ByteString.php, line 236
Class
- ByteString
- Represents a binary-safe string of bytes.
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, $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;
}