从基于十六进制值的字符串删除特定的字符 - C# [英] Remove specific character from a string based on Hex value - C#

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

问题描述

虽然从平面文件导入数据时,我注意到,有些行已嵌入式非中断空格(十六进制: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?

推荐答案

为什么不与string.replace ?工作

Why doesn't string.Replace work?

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

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

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