删除非ascii字符删除中文字符 [英] Remove non ascii characters removes chinese characters
本文介绍了删除非ascii字符删除中文字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下正则表达式从字符串中删除非ascii:
I'm using the following regular expression to remove non ascii from a string:
Regex.Replace(item, @"[^\u0020-\u007E]", string.Empty);
解析中文字符串时遇到问题。它完全删除了我不想要的所有字符。周围有吗?
我尝试过:
我试过以下
I'm coming into a problem when parsing a chinese string. It removes all the characters completely which I don't want. Is there away around this?
What I have tried:
I've tried the following
Regex.Replace(item, @"[^\u0020-\u007E]", string.Empty);
推荐答案
嗯,中文字符是Unicode字符,根据定义,它们是非ascii。您期望得到什么结果?
Well, Chinese characters are Unicode characters, which are, by definition, non-ascii. What result did you expect?
这篇关于删除非ascii字符删除中文字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文