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));
}