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

Breadcrumb

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

function Preg::matchWithOffsets

Runs preg_match with PREG_OFFSET_CAPTURE

@param-out array<int|string, array{string|null, int<-1, max>}> $matches

Parameters

non-empty-string $pattern:

array<mixed> $matches Set by method:

int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_OFFSET_CAPTURE are always set, no other flags are supported:

Return value

0|1

2 calls to Preg::matchWithOffsets()
Preg::isMatchWithOffsets in vendor/composer/pcre/src/Preg.php
Variant of matchWithOffsets() which returns a bool instead of int
Regex::matchWithOffsets in vendor/composer/pcre/src/Regex.php
Runs preg_match with PREG_OFFSET_CAPTURE

File

vendor/composer/pcre/src/Preg.php, line 70

Class

Preg

Namespace

Composer\Pcre

Code

public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : int {
    $result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
    if ($result === false) {
        throw PcreException::fromFunction('preg_match', $pattern);
    }
    return $result;
}
RSS feed
Powered by Drupal