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

Breadcrumb

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

function Preg::replaceCallbackStrictGroups

Variant of `replaceCallback()` which outputs non-null matches (or throws)

@param-out int<0, max> $count

Parameters

string $pattern:

($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string, int<0, max>}>): string) : callable(array<int|string, string>): string) $replacement:

string $subject:

int $count Set by method:

int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set:

1 call to Preg::replaceCallbackStrictGroups()
Regex::replaceCallbackStrictGroups in vendor/composer/pcre/src/Regex.php
Variant of `replaceCallback()` which outputs non-null matches (or throws)

File

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

Class

Preg

Namespace

Composer\Pcre

Code

public static function replaceCallbackStrictGroups(string $pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0) : string {
    return self::replaceCallback($pattern, function (array $matches) use ($pattern, $replacement) {
        return $replacement(self::enforceNonNullMatches($pattern, $matches, 'replaceCallback'));
    }, $subject, $limit, $count, $flags);
}
RSS feed
Powered by Drupal