if( System.Text.RegularExpressions.Regex.IsMatch(YourString,@"^[\u4E00-\u9FA5]+$"))
{
 //yes
}

解决方案 »

  1.   

    这个是针对中文么?还有英文呢
    另外。字符串不只有中文或者英文。
    比如字符串 “你好!Rob” 包含中文也包含英文。可以解决么?
      

  2.   

    中文/日文/韩文: [\u4E00-\u9FA5]
    英文:[a-zA-Z]if( System.Text.RegularExpressions.Regex.IsMatch(YourString,@"^[\u4E00-\u9FA5a-zA-Z]+$"))
    {
     //yes
    }
      

  3.   

    为什么最后lg没有任何输出?
    string Song_name = "大家好 - hello";
    string LG = null;
    if (System.Text.RegularExpressions.Regex.IsMatch(Song_name,@"^[\u4E00-\u9FA5a-zA-Z]+$"))
    {
    //中文/英文混合
    LG = "3";
    MessageBox.Show ("3");
    }
    else
    {
    if (System.Text.RegularExpressions.Regex.IsMatch(Song_name,@"^[a-zA-Z]+$"))
    {
    //英文
    LG = "2";
    MessageBox.Show ("2");
    }
    if (System.Text.RegularExpressions.Regex.IsMatch(Song_name,@"^[\u4E00-\u9FA5]+$"))
    {
    //中文
    LG = "1";
    MessageBox.Show ("1");
    }
    }
      

  4.   

    "大家好 - hello", you have " " and "-" in it
      

  5.   

    判断前把这2种字符去掉。
    Song_name.Replace(" ","").Repalce("-","")
      

  6.   

    改了一下你程序中的判断顺序using System;

    class fen
    {
    static void Main()
    {
    string Song_name = Console.ReadLine();
    string LG = null;
    if (System.Text.RegularExpressions.Regex.IsMatch(Song_name.Replace(" ","").Replace("-",""),@"^[\u4E00-\u9FA5]+$"))
    {
    //中文
    LG = "中文";
    Console.WriteLine(LG);
    }
    else if (System.Text.RegularExpressions.Regex.IsMatch(Song_name.Replace(" ","").Replace("-",""),@"^[a-zA-Z]+$"))
    {
    //英文
    LG = "英文";
    Console.WriteLine(LG);
    }
    else if (System.Text.RegularExpressions.Regex.IsMatch(Song_name.Replace(" ","").Replace("-",""),@"^[\u4E00-\u9FA5a-zA-Z]+$"))
    {
    //中文/英文混合中文
    LG = "中英文混合";
    Console.WriteLine(LG);
    }
    }
    }
      

  7.   

    what do you want to match? 中文/日文/英文/韩文 alone? otherwise, why do you want to match in the first place?
      

  8.   

    理论上是不能百分之百判断准确的,因为他们的内码有重叠,如果正好是重叠区中的文字怎么办呢
    另外还要看你的中日韩是用的什么字符集,如果全是unicode可能要好办一些。
    你看IE他能百分之百判断准确文种吗?不行