0730-8232398,8242200
上面这个字符串,如果考虑“,”是全角的情况,该如何做?下面我用的这个是错误的,没有正确判断符号是全角的情况,全角的符号用正则表达式该如何取呢?
public static string GetStrLen(string s, int len, string style)
        {
            string temp = s;
            if (Regex.Replace(temp, "[\u4e00-\u9fa5]", "zz", RegexOptions.IgnoreCase).Length <= len)
            {
                return temp;
            }
            for (int i = temp.Length; i >= 0; i--)
            {
                temp = temp.Substring(0, i);
                if (Regex.Replace(temp, "[\u4e00-\u9fa5]", "zz", RegexOptions.IgnoreCase).Length <= len - style.Length)
                {
                    return temp + style;
                }
            }
            return "";
        }