根据十六进制值从字符串中删除特定字符
从平面文件导入数据时,我注意到某些行嵌入了不间断空格(十六进制:A0)。
我想删除这些,但标准 string.replace 似乎不起作用,并考虑使用正则表达式来替换字符串,但不知道正则表达式会搜索什么来删除它。
有没有更好的方法,而不是将整个字符串转换为十六进制并检查它?
While importing data from a flat file, I noticed that some of lines have embedded non breaking spaces (Hex: A0).
I would like to remove these, but the standard string.replace doesn't seem to work and had considered using regex to replace the string but wouldn't know what the regex would search for to remove it.
Rather than converting the whole string to hex and examining that, is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为什么 string.Replace 不起作用?
Why doesn't string.Replace work?
这应该可以做到。
This ought to do it.
string.Replace 确实有效。不使用正则表达式:
string.Replace does work. Without using RegEx:
这对你有用吗?
“
\n
”是 ASCII 换行,“\r
”是回车。Would this work for you?
"
\n
" is ASCII LineFeed, "\r
" is Return.