public static function strspn($str, $mask, $start = null, $length = null)
    {
        $mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\${1}', $mask);

        if ($start !== null || $length !== null) {
            $str = AnHelperString::substr($str, $start, $length);
        }

        preg_match('/^['.$mask.']+/u', $str, $matches);

        if (isset($matches[0])) {
            return AnHelperString::strlen($matches[0]);
        }

        return 0;
    }