zoukankan      html  css  js  c++  java
  • 正则过滤汉字

    Regex reg = new Regex(@"[\u4e00-\u9fa5]+"); string content = "13440900984\r\n13440900984\r\n你好\r\n13440900984\r\n你好\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984你好\r\n鸟\r\n13440900984\r\n13440900984\r\n"; string result = reg.Replace(content, ""); richTextBox2.Text = result;

    unsafe static void kickoffChinese3()
            {
                //string content = "13440900984\r\n13440900984\r\n你好\r\n13440900984\r\n你好\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984你好\r\n鸟\r\n13440900984\r\n13440900984\r\n";
                char[] chars = content.ToCharArray();
                char[] result = new char[chars.Length];

                fixed (char* pChars = chars)
                {
                    fixed (char* pResult = result)
                    {
                        char* pCurrentChars = pChars;
                        char* pCurrentResult = pResult;
                        char* pLimit = pChars + chars.Length;
                        while (pCurrentChars < pLimit)
                        {
                            if (*pCurrentChars < 0x4E00 || *pCurrentChars > 0x9FA5)
                                *pCurrentResult++ = *pCurrentChars;
                            pCurrentChars++;
                        }
                        *pCurrentResult = '\0';
                    }
                }
                //Console.WriteLine(new string(result));
            }

  • 相关阅读:
    nmap加快扫描速度(转载)
    deepin换源
    利用74HC595实现的流水灯 Arduino
    解决用vscode开发arduino时Serial未定义
    JS获取格式为YYYY-MM-DD的当前日期
    链式前向星存图
    Nginx+FFmpeg实现RTSP转RTMP
    非root用户安装centos的jdk
    Nginx配置请求头
    Eclipse-Che 安装(Centos)
  • 原文地址:https://www.cnblogs.com/zzxap/p/2175781.html
Copyright © 2011-2022 走看看