Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractUnicodeString.php

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\String

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal