简体   繁体   English

需要有关正则表达式或字符串替换的帮助

[英]need help on regex or string replace

I want to replace all the content between this block with empty string,what's the better way to do it.Before replacing string the content would look like 我想用空字符串替换这个块之间的所有内容,这是更好的方法。在替换字符串之前,内容看起来像

 Customer Request Message......
[[REQUEST_Data]]
KEY=VALUE
KEY=VALUE
KEY=VALUE
[[/REQUEST_Data]]

After replacing the content would become Customer Request Message...... All the content between [[REQUEST_Data]] [[/REQUEST_Data]] must be replaced with empty string and also both the tag is also replace with empty string. 更换后的内容将成为客户请求消息...... [[REQUEST_Data]] [[/ REQUEST_Data]]之间的所有内容必须替换为空字符串,并且标签也都替换为空字符串。

var regex = @"\[\[REQUEST_Data\]\](\n|\r|\r\n|.)*\[\[\/REQUEST_Data\]\]"
var replaced = Regex.Replace(input, regex, "");

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

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