public function filter($string, $replacement = '')
    {
        if ($replacement !== '') {
            return preg_replace_callback(static::REGEX_ANSI, function ($matches) use ($replacement) {
                return str_repeat($replacement, mb_strlen($matches[0]));
            }, $string);
        }
        return preg_replace(static::REGEX_ANSI, $replacement, $string);
    }