基于十六进制值从字符串中删除特定字符 [英] Remove specific character from a string based on hex value

查看:136
本文介绍了基于十六进制值从字符串中删除特定字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从平面文件导入数据时,我注意到一些行嵌入了非空格(Hex:A0)。

While importing data from a flat file, I noticed that some of lines have embedded non breaking spaces (Hex: A0).

我想删除这些,但标准的string.replace似乎并没有工作,并已考虑使用正则表达式来替换字符串,但不知道什么正则表达式会搜索删除它。

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?

推荐答案

为什么没有string.Replace工作?

Why doesn't string.Replace work?

stringVar.Replace((char)0xA0, ' ');

这篇关于基于十六进制值从字符串中删除特定字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆