src/Gobie/Regex/Wrappers/Pcre/PcreRegex.php
public static function filter($pattern, $replacement, $subject, $limit = -1)
    {
        static::setUp($pattern);
        $res = \preg_filter($pattern, $replacement, $subject, $limit);
        static::tearDown();
        static::handleError($pattern);

        return $res;
    }
public static function filter($pattern, $replacement, $subject, $limit = -1)
    {
        static::setUp($pattern);
        $res = \preg_filter($pattern, $replacement, $subject, $limit);
        static::tearDown();
        static::handleError($pattern);

        return $res;
    }
Regular expression filter and return only replaced.

@param string|string[] $pattern     Pattern or array of patterns
@param string|string[] $replacement Replacement or array of replacements
@param string|string[] $subject     Subject or array of subjects
@param int             $limit       Limit of replacements
@return string|string[] Replaced subject or array of subjects
@throws PcreRegexException When compilation or runtime error occurs
@link http://php.net/function.preg-filter.php