2Million documents;total 1TB volume)" />
开发者

How to remove control chars from UTF8 string

开发者 https://www.devze.com 2023-01-31 10:30 出处:网络
i have a VB.NET program that handles the content of documents. The programm handles high volumes of documents as \"batc开发者_StackOverflow中文版h\"(>2Million documents;total 1TB volume)

i have a VB.NET program that handles the content of documents. The programm handles high volumes of documents as "batc开发者_StackOverflow中文版h"(>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?

Thanks!


Try

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

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


Here is the POSIX regex for control characters: [:cntrl:], from Regular Expression on Wikipedia.

0

精彩评论

暂无评论...
验证码 换一张
取 消