C# 使用正则表达式删除unicode十六进制值
我需要从一系列产品描述中删除几个不同的十六进制值 示例:“C# 使用正则表达式删除unicode十六进制值,c#,regex,unicode,hex,C#,Regex,Unicode,Hex,我需要从一系列产品描述中删除几个不同的十六进制值 示例:“CoolItem和#x2122;Watch上的销售”或“Rmkoody和#8482;上的交易破坏者签名” 在这个大型数据库中只有几个十六进制字符串 我需要一个reg exp用一个空字符串替换每个 结果:“在CoolItem Watch上的销售”或“在Rmkoody上的交易破坏者签名” reg exp将如何查找半列并选择前进到&并替换整个选择 更新/解决方案工作代码 string s = "Sale on CoolItem!
CoolItem和#x2122;Watch上的销售
”或“Rmkoody和#8482;上的交易破坏者签名
”
在这个大型数据库中只有几个十六进制字符串
我需要一个reg exp用一个空字符串替换每个
结果:“在CoolItem Watch上的销售
”或“在Rmkoody上的交易破坏者签名
”
reg exp将如何查找半列并选择前进到&并替换整个选择
更新/解决方案工作代码
string s = "Sale on CoolItem™ Watch"
var cleanProductName = Regex.Replace(s, @"&#x?[^;]{2,4};", string.Empty);
cleanProductName = "Sale on CoolItem Watch"
string s = "Deal buster on RMKHoody™ signed"
var cleanProductName = Regex.Replace(s, @"&#x?[^;]{2,4};", string.Empty);
cleanProductName = "Deal buster on RMKHoody signed"
你也可以使用
var cleanProductName = Regex.Replace(s, @"&[^;]{1,6};", string.Empty);
有关更多spec char,如®。™ . °
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
可以作为一个起点。您可以尝试?[^;]{2,4}
,意思是:和#
后跟零或一个x
后跟2到4个非字符代码>,后跟代码>你有什么东西吗?
var cleanProductName = Regex.Replace(s, @"&[^;]{1,6};", string.Empty);