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.
精彩评论