开发者

.Net Regex for Latin-1 Supplement (\x80-\xFF) Characters

I am working with user submitted files that have a number of invalid characters in them, most of them do to MS Word converting things like hyphens to en-dashes or quotes to "smart quotes". I am writing a method to replace several of these specifically (e.g. convert en-dashes back开发者_StackOverflow社区 to hyphens) and now I need to replace all other "invalid" characters with a space. So my first attempt was to use regex to match the invalid characters with "[\x80-\xFF]" then replace only the matches. My thought was that only looping through the matches would be much quicker than 127 replaces in the form of blah=blah.replace(chr(128)," ").

The issue I'm having is that .net regex doesn't seem to match or replace on the hex values above \x7F (dec 127). Is there a way to set .net regex to use the full unicode character set?

Thanks in advance.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜