Automattic\WooCommerce\Vendor\Pelago\Emogrifier\Utilities

Preg::splitpublicWC 1.0

Wraps preg_split. If an error occurs, and exceptions are not being thrown, a single-element array containing the original $subject is returned. This method does not support the PREG_SPLIT_OFFSET_CAPTURE flag and will throw an exception if it is specified.

Method of the class: Preg{}

No Hooks.

Returns

Array. string>

Usage

$Preg = new Preg();
$Preg->split( $pattern, $subject, $limit, $flags ): array;
$pattern(non-empty-string) (required)
.
$subject(string) (required)
.
$limit(int)
.
Default: -1
$flags(int)
.

Preg::split() code WC 10.5.0

public function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
{
    if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
        throw new \RuntimeException('PREG_SPLIT_OFFSET_CAPTURE is not supported by Preg::split', 1726506348);
    }

    $result = \preg_split($pattern, $subject, $limit, $flags);

    if ($result === false) {
        $this->logOrThrowPregLastError();
        $result = [$subject];
    }

    return $result;
}