3
我不知道为什么这只适用于找到的最后一个实例,不是我所期望的所有实例。任何帮助赞赏。VBscript正则表达式替换
输入字符串:
<a href="http://www.scirra.com" target="_blank" rel="nofollow">http://www.scirra.com</a><br /><br />
<a href="http://www.scirra.com" target="_blank" rel="nofollow">http://www.scirra.com</a><br /><hr>
正则表达式:
'SEO scirra links
Dim regEx
Set regEx = New RegExp
' BB code urls
With regEx
.Pattern = "<a href=\""http://www.scirra.com([^\]]+)\"" target=\""_blank\"" rel=\""nofollow\"">"
.IgnoreCase = True
.Global = True
.MultiLine = True
End With
strMessage = regEx.Replace(strMessage, "<a href=""http://www.scirra.com$1"" target=""_blank"" title=""Some value insert here"">")
set regEx = nothing
输出:
<a href="http://www.scirra.com" target="_blank" rel="nofollow">http://www.scirra.com</a><br /><br />
<a href="http://www.scirra.com" target="_blank" title="Some value insert here">http://www.scirra.com</a><br /><hr>
谁能阐明了为什么只是将标题添加到上次找到的实例? (我有更多的测试,总是只适用于最后一个)
谢谢!它的意思是匹配所有以http://www.scirra.com开头的网址,剥离nofollow。我仍然努力工作,'http://www.scirra.com(。*)'不符合他们任何一个,我需要什么? – 2012-01-14 02:10:15
“剥离nofollow”?你什么意思? – fge 2012-01-14 02:10:52
这是我正在对论坛进行的一项修改,我正在剥离网站内部发布的链接的nofollow属性以及添加标题属性 – 2012-01-14 02:12:36