私はこれがなぜ最後のインスタンスにしか適用されないのか分かりません。どんな助けもありがたい。VBscript regex replace
入力文字列:
<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>
誰でも上に光を当てることができます最後に見つかったインスタンスにタイトルを追加するのはなぜですか? (私はいつも一つだけを最後に適用され、より多くのをテストしてみた)
Dohありがとう!これは、http://www.scirra.comで始まるすべてのURLを一致させ、nofollowを取り除くことを意味します。私はまだそれを稼働させるのに苦労しています。「http://www.scirra.com(。*)」はどちらにも一致しません。何が必要ですか? –
"nofollowを外す"?どういう意味ですか? – fge
それは私がフォーラムのnofollowアトリビュートを削除してサイトの内部にあり、タイトルアトリビュートを追加するフォーラムにしています –