简体   繁体   English

过滤字符串

[英]Filtering strings

I'am trying to filter a string with Regex.Replace, but I'am stuck on Replacing text like this: [02] or [06]. 我正在尝试使用Regex.Replace过滤字符串,但是我却坚持使用[02]或[06]这样的替换文本。

The code I'am using now is: 我现在使用的代码是:

string cleanData = Regex.Replace(stringtext, "[..]", "");

Does anybody have any ideas? 有人有什么想法吗?

Use 采用

string cleanData = Regex.Replace(stringtext, @"\[..\]", "");

(cannot test it). (无法测试)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM