C#如何判断中文标点符号??

解决方案 »

  1.   

    枚举出来,然后匹配。
    string symbol = ",。;?~!:‘“”’【】()";
      

  2.   

    我不知道。但是我搜索了一下,从07年到现在的csdn帖子和其他google搜索结果中都没有比较好的方式。等等看谁有好办法吧。
      

  3.   


    //枚举出来就可以了
    Regex regex = new Regex(@"[,。;?~!:‘“”’【】()]");
    if (r.IsMatch(",。"))
                {
                    Console.WriteLine(" is match ");
                }
      

  4.   

    Regex regex = new Regex(@"[,。;?~!:‘“”’【】()]");
    if (r.IsMatch(",。"))
                {
                    Console.WriteLine(" is match ");
                }
      

  5.   

    using System.Text.RegularExpressions;//先导入这个使用正则表达式         Regex reg = new Regex(@"[\u4e00-\u9fa5]");//正则表达式
                string str="smile 卡";
                if (reg.IsMatch(str))
                {
                    Console.WriteLine("有汉字");
                }
                else
                {
                    Console.WriteLine("没汉字");
                } 
    参考吧
      

  6.   


    用正则表达式判断Regex regex = new Regex(@"[,。;?~!:‘“”’【】()]")
      

  7.   

    自己搞定了,我用unicode编码方式返回byte数组,然后判断数组的值。
      

  8.   


    //方法很笨,很简单,不要见笑啊public bool getFlat(string noKnow)
    {
       byte[] bArry=System.Text.encoding.Unicode.getbytes(noKnow);
       if( bArry.Length=2)
        {
            if(bArry[1]!=0) return true;  else return false;  //当然noKnow有可能是汉字,因为汉字也是两个字节,但是汉字我已经用其他正则方法判断了,所以noKnow是不会有汉字传入的,有两个字节的就为 中文字符。方法笨,并且可能只适用我自己的应用。
        }}
      

  9.   

    //上面写错了,更正下方法public bool getFlat(string noKnow)
    {
       bool falt=false;
       byte[] bArry=System.Text.encoding.Unicode.getbytes(noKnow);
       if( bArry.Length=2)
        {
            if(bArry[1]!=0) falt=true; 
        }
        return falt;
        }