public function replace(string $subject, string $replacement, int $limit = -1, int &$count = null) : string
    {
        $result = preg_replace($this->pattern->getPattern() . $this->modifier, $replacement, $subject, $limit, $count);

        if (($errno = preg_last_error()) !== PREG_NO_ERROR) {
            $message = array_flip(get_defined_constants(true)['pcre'])[$errno];
            switch ($errno) {
                case PREG_INTERNAL_ERROR:
                    throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_BACKTRACK_LIMIT_ERROR:
                    throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_RECURSION_LIMIT_ERROR:
                    throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_BAD_UTF8_ERROR:
                    throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_BAD_UTF8_OFFSET_ERROR:
                    throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_JIT_STACKLIMIT_ERROR:
                    throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
            }
        }

        return $result;
    }
public function replace(string $subject, string $replacement, int $limit = -1, int &$count = null) : string
    {
        $result = preg_replace($this->pattern->getPattern() . $this->modifier, $replacement, $subject, $limit, $count);

        if (($errno = preg_last_error()) !== PREG_NO_ERROR) {
            $message = array_flip(get_defined_constants(true)['pcre'])[$errno];
            switch ($errno) {
                case PREG_INTERNAL_ERROR:
                    throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_BACKTRACK_LIMIT_ERROR:
                    throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_RECURSION_LIMIT_ERROR:
                    throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_BAD_UTF8_ERROR:
                    throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_BAD_UTF8_OFFSET_ERROR:
                    throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
                case PREG_JIT_STACKLIMIT_ERROR:
                    throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno);
            }
        }

        return $result;
    }
public function replace ( string $ subject , string $ replacement , int $ limit = - 1 , int & $ count = null ) : string { $ result = preg_replace ( $ this -> pattern -> getPattern ( ) . $ this -> modifier , $ replacement , $ subject , $ limit , $ count ) ; if ( ( $ errno = preg_last_error ( ) ) !== PREG_NO_ERROR ) { $ message = array_flip ( get_defined_constants ( true ) [ 'pcre' ] ) [ $ errno ] ; switch ( $ errno ) { case PREG_INTERNAL_ERROR : throw new InternalException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_BACKTRACK_LIMIT_ERROR : throw new BacktrackLimitException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_RECURSION_LIMIT_ERROR : throw new RecursionLimitException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_BAD_UTF8_ERROR : throw new BadUtf8Exception ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_BAD_UTF8_OFFSET_ERROR : throw new BadUtf8OffsetException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; case PREG_JIT_STACKLIMIT_ERROR : throw new JitStackLimitException ( "{$message} using pattern: {$this->pattern->getPattern()}" , $ errno ) ; } } return $ result ; }
Retrieve replaced subject with replacement
@param string $subject
@param string $replacement
@param int $limit
@param int|null $count
@return string
@throws BacktrackLimitException
@throws BadUtf8Exception
@throws BadUtf8OffsetException
@throws InternalException
@throws JitStackLimitException
@throws RecursionLimitException
Retrieve replaced subject with replacement