bool isChinses = System.Text.RegularExpressions.Regex.IsMatch(strSearchKey, @"[\u4e00-\u9fa5]+$");

/////////////////////

string   s   =   "hello你好";   
  for(int   i   =   0;i<s.Length,i++)   
    {   
        if((s[i]>'a'   &&   s[i]<'z')   ||   (s[i]>'A'   &&   s[i]<'Z'   ))   
              {System.Console.WriteLind("s["+{0}+"]   is   a   English   Letter",i}   
    }   



////////////////////////////////////
private static bool IsHanZi(string ch)
{
     byte[] byte_len = System.Text.Encoding.Default.GetBytes(ch);
     if (byte_len.Length == 2) { return true; }

     return false;
}



//////////////////////////////////////////////////////

匹配中文:[\u4e00-\u9fa5]*。

示例:MatchCollection var=  Regex.Matches("中国isguyoj国家", @"[\u4e00-\u9fa5]+");

var其中的值为"中国","国家".

匹配英文[a-zA-Z]*

示例:MatchCollection var= Regex.Matches("中国isguyoj国家", @"[a-zA-Z]*");

var其中的值为"isguyoj".

至于长度问题,你中文匹配出来的,计算总长然后乘以2,英文计算总长,两个相加不超过20就行了

相关文章:

  • 2021-12-09
  • 2021-12-29
  • 2021-10-28
  • 2020-07-08
  • 2021-11-04
  • 2021-11-20
  • 2021-11-13
  • 2021-11-07
猜你喜欢
  • 2021-12-30
  • 2021-10-15
  • 2021-09-18
  • 2021-10-15
  • 2021-08-07
  • 2021-12-04
  • 2021-11-27
  • 2021-12-27
相关资源
相似解决方案