src/GetAllMatchesRegexCapablePcreTrait.php
protected function _getAllMatchesRegex($pattern, $subject)
    {
        $matches = [];
        $pattern = $this->_normalizeString($pattern);
        $subject = $this->_normalizeString($subject);

        try {
            $result = @preg_match_all($pattern, $subject, $matches);
        } catch (RootException $e) {
            // This will happen if a custom error handler is set and throws exceptions for regex errors
            throw $this->_createRuntimeException($this->__($e->getMessage()), null, $e);
        }

        if ($result === false) {
            $errorCode = preg_last_error();
            throw $this->_createRuntimeException($this->__('RegEx error code "%1$s"', [$errorCode]));
        }

        return $matches;
    }
protected function _getAllMatchesRegex($pattern, $subject)
    {
        $matches = [];
        $pattern = $this->_normalizeString($pattern);
        $subject = $this->_normalizeString($subject);

        try {
            $result = @preg_match_all($pattern, $subject, $matches);
        } catch (RootException $e) {
            // This will happen if a custom error handler is set and throws exceptions for regex errors
            throw $this->_createRuntimeException($this->__($e->getMessage()), null, $e);
        }

        if ($result === false) {
            $errorCode = preg_last_error();
            throw $this->_createRuntimeException($this->__('RegEx error code "%1$s"', [$errorCode]));
        }

        return $matches;
    }
protected function _getAllMatchesRegex ( $ pattern , $ subject ) { $ matches = [ ] ; $ pattern = $ this -> _normalizeString ( $ pattern ) ; $ subject = $ this -> _normalizeString ( $ subject ) ; try { $ result = @ preg_match_all ( $ pattern , $ subject , $ matches ) ; } catch ( RootException $ e ) { // This will happen if a custom error handler is set and throws exceptions for regex errors throw $ this -> _createRuntimeException ( $ this -> __ ( $ e -> getMessage ( ) ) , null , $ e ) ; } if ( $ result === false ) { $ errorCode = preg_last_error ( ) ; throw $ this -> _createRuntimeException ( $ this -> __ ( 'RegEx error code "%1$s"' , [ $ errorCode ] ) ) ; } return $ matches ; }
Retrieves all matches that correspond to a RegEx pattern from a string.

@since [*next-version*]
@see preg_match_all()

@param string|Stringable $pattern The RegEx pattern to use for matching.
@param string|Stringable $subject The subject that will be searched for matches.

@throw InvalidArgumentException If the pattern or the subject are of the wrong type.
@throw RuntimeException If problem matching.

@return array The array of matches. Format is same as the matches produced by `preg_match_all()`.
Retrieves all matches that correspond to a RegEx pattern from a string .