asp正则表达式RegExp的Replace方法
[ 2010-05-24 22:20:21 | 作者: admin ]
Function StrReplace(s As String, p As String, r As String) As String
Dim re As RegExp
Set re = New RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern = p
StrReplace = re.Replace(s, r)
End Function
Private Sub Command2_Click()
Dim s As String '字符串
Dim p As String '正则表达式
Dim r As String '要替换的字符串
'以下代码是替换邮箱地址
s = "我的E-mail: Test@163.com 。欢迎致电!"
p = "w+@w+.w+"
r = "E_Mail@sohu.net"
s = StrReplace(s, p, r)
Debug.Print s
'结果:我的E-mail: E_Mail@sohu.net 。欢迎致电!
End Sub
http://hi.baidu.com/%B7%BF%B6%F7%BA%EA/blog/item/8fda53b1f00df6510923024e.html
Dim re As RegExp
Set re = New RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern = p
StrReplace = re.Replace(s, r)
End Function
Private Sub Command2_Click()
Dim s As String '字符串
Dim p As String '正则表达式
Dim r As String '要替换的字符串
'以下代码是替换邮箱地址
s = "我的E-mail: Test@163.com 。欢迎致电!"
p = "w+@w+.w+"
r = "E_Mail@sohu.net"
s = StrReplace(s, p, r)
Debug.Print s
'结果:我的E-mail: E_Mail@sohu.net 。欢迎致电!
End Sub
http://hi.baidu.com/%B7%BF%B6%F7%BA%EA/blog/item/8fda53b1f00df6510923024e.html
评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=1403
这篇日志没有评论。
此日志不可发表评论。