語言的元字符:ASP如何逃脫正則表達式
這是我的代碼示例:
str = "www.example.com/gotobuy.aspx?id=1234"
key_word = ".obuy."
Dim regEx
Set regEx = New RegExp
regEx.Pattern = key_word
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(str)
if matches.count > 0 then
new_string = str
For Each Match in Matches
new_string = replace(new_string,match.value,"")
Next
else
new_string = str
end if
response.write new_string
的響應將顯示:
www.example.com/goaspx?id=1234
我知道(。 )是元字符之一。但是如果我想(。)只是(。)而不是任何單個單詞。我該怎麼辦?
感謝您的幫助!
沒有提出的,徵求意見:使用RegExp.Replace()而不是取代():`new_string = regEx.Replace(STR, '')`。這樣你就不需要循環比賽。 – outis 2009-05-25 05:06:07