如何从UTF8字符串控制字符字符串、字符

2023-09-03 13:49:27 作者:俺要回到幼儿园当学霸i

我有一个处理文档内容的VB.NET程序。 该PROGRAMM处理大容量的文件为批(> 200万文件;总1TB容量) 其中的一些文件可能包含控制字符或字符像f0e8(http://www.fileformat.info/info/uni$c$c/char/f0e8/browsertest.htm)。

i have a VB.NET program that handles the content of documents. The programm handles high volumes of documents as "batch"(>2Million documents;total 1TB volume) Some of this documents may contain control chars or chars like f0e8(http://www.fileformat.info/info/unicode/char/f0e8/browsertest.htm).

有一个简单的,特别是快的方式来删除字符?(除空格,换行,标签,...) 如果答案是正则表达式:?有没有人一个的完成的正则表达式我

Is there a easy and especially fast way to remove that chars?(except space,newline,tab,...) If the answer is regex: Has anyone a complete regex for me?

谢谢!

推荐答案

尝试

resultString = Regex.Replace(subjectString, "\p{C}+", "");

这将从字符串中删除所有的其他统一code字(控制,格式,私人使用,替代,和未分配)。

This will remove all "other" Unicode characters (control, format, private use, surrogate, and unassigned) from your string.