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

Breadcrumb

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

function Preg::matchAllWithOffsets

Runs preg_match_all with PREG_OFFSET_CAPTURE

@param-out array<int|string, list<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_MATCH_OFFSET are always set, no other flags are supported:

Return value

0|positive-int

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

File

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

Class

Preg

Namespace

Composer\Pcre

Code

public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : int {
    self::checkSetOrder($flags);
    $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
    if (!is_int($result)) {
        // PHP < 8 may return null, 8+ returns int|false
        throw PcreException::fromFunction('preg_match_all', $pattern);
    }
    return $result;
}
RSS feed
Powered by Drupal