我有以下字符串正则表达式
"choose to still go on the trip. <br><br>\r\nNote that when booking"在使用正则表达式转换后,我只需要用一个<br>替换<br>标记,因此字符串将如下所示
"choose to still go on the trip. <br>Note that when booking"发布于 2013-04-23 18:33:09
如果您需要考虑标签之间有空格的情况,请尝试以下regex:
myInputStr = Regex.Replace(myInputStr,
@"([\b\s]*<[\b\s]*[bB][rR][\s]*/?[\b\s]*>){2,}",
"<br>", RegexOptions.Multiline);此正则表达式将用单个实例替换2个或更多个<br>标记实例,而不考虑标记的形式(间距、大小写、自闭合等)。
https://stackoverflow.com/questions/16166954
复制相似问题