| | |
| | | content = content.Replace(" ", string.Empty);
|
| | | return content;
|
| | | }
|
| | |
|
| | | public static bool SatisfyNameLength(string name, out int error)
|
| | | {
|
| | | error = 0;
|
| | | bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
|
| | | var chsCount = GetChsCount(name);
|
| | | var maxlength = pureChinese ? 5 : chsCount > 0 ? 6 : 8;
|
| | | var minlength = pureChinese ? 2 : 3;
|
| | | if (name.Length > maxlength)
|
| | | {
|
| | | error = 1;
|
| | | }
|
| | | else if (name.Length < minlength)
|
| | | {
|
| | | error = 2;
|
| | | }
|
| | | return error == 0;
|
| | | }
|
| | |
|
| | | public static int GetChsCount(string name)
|
| | | {
|
| | | var count = 0;
|
| | | for (int i = 0; i < name.Length; i++)
|
| | | {
|
| | | if (Regex.IsMatch(name[i].ToString(), "[\u4e00-\u9fa5]"))
|
| | | {
|
| | | count++;
|
| | | }
|
| | | }
|
| | | return count;
|
| | | }
|
| | | }
|