正则表达式匹配中文与双字节的代码

  匹配中文字符

  [\u4e00-\u9fa5]

  C#

  

复制代码 代码如下:

  class Class1

  {

  static void Main()

  {

  string s = "中文 chinese";

  Regex regx = new Regex("[\u4e00-\u9fa5]+");

  Match m = regx.Match(s);

  Console.WriteLine(m.Groups[0].Value); // 中文

  Console.ReadKey();

  }

  }

  匹配双字节字符(包括汉字)

  [^\x00-\xff]