Automattic\WooCommerce\Vendor\Pelago\Emogrifier\Utilities

Preg::replacepublicWC 1.0

Wraps preg_replace, though does not support $subject being an array. If an error occurs, and exceptions are not being thrown, the original $subject is returned.

Method of the class: Preg{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Preg = new Preg();
$Preg->replace( $pattern, $replacement, $subject, $limit, ?int $count ): string;
$pattern(non-empty-string|non-empty-array) (required)
.
$replacement(string|non-empty-array) (required)
.
$subject(string) (required)
.
$limit(int)
.
Default: -1
?int $count(passed by reference — &)
.
Default: null

Preg::replace() code WC 10.5.0

public function replace($pattern, $replacement, string $subject, int $limit = -1, ?int &$count = null): string
{
    $result = \preg_replace($pattern, $replacement, $subject, $limit, $count);

    if ($result === null) {
        $this->logOrThrowPregLastError();
        $result = $subject;
    }

    return $result;
}