7.12.11

Chuẩn hóa xâu nhập họ tên

public static string FormatProperCase(string str)
        {
            CultureInfo cultureInfo = new CultureInfo("vi-VN");
            TextInfo textInfo = cultureInfo.TextInfo;
            str = textInfo.ToLower(str);
            // Replace multiple white space to 1 white  space
            str = System.Text.RegularExpressions.Regex.Replace(str, @"\s{2,}", " ");
           //Upcase like Title
            return textInfo.ToTitleCase(str);
        }

0 comments: