正则表达式替换不起作用< span style =" mso-bookmark:OLE_LINK1"> [英] regex replace is not working <span style="mso-bookmark: OLE_LINK1">

查看:442
本文介绍了正则表达式替换不起作用< span style =" mso-bookmark:OLE_LINK1">的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更换span标签,因为第三方报告工具中的问题会修剪空格。

I am trying to replace the span tags as the spaces are trimmed due to problem in third party reporting tool.

所以html看起来像< span style =" mso-bookmark:OLE_LINK1">我希望它替换为< span>& nbsp; 但不知怎的,它不起作用。我的输入字符串是单词的长字符串,我喜欢替换所有出现。

So the html looks like <span style="mso-bookmark: OLE_LINK1"> and I want it replace with <span>&nbsp; but somehow it is not working. My input string is long string from word and I like to replace all occurances.

我的代码看起来像这样......

my code looks like this...

myComment = Regex .Replace(myComment, "< span style = \" mso-bookmark :OLE_LINK [^>] *" "< span>& nbsp;" RegexOptions .Multiline | RegexOptions .IgnoreCase);

myComment= Regex.Replace(myComment, "<span style=\"mso-bookmark: OLE_LINK[^>]* ", "<span>&nbsp;", RegexOptions.Multiline|RegexOptions.IgnoreCase);

是否有正则表达的专家可以提供帮助。

is there any expert of regex who can help.

谢谢提前

thanks in advance

推荐答案


您可以试试这个:

正则表达式
.Replace(myComment, "< span style = \" mso-bookmark:OLE_LINK \"> +" "< span>& nbsp;" );


这篇关于正则表达式替换不起作用&lt; span style =&quot; mso-bookmark:OLE_LINK1&quot;&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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