当前位置:首页>>网络编程>>ASP教程>>正文

ASP自定义函数:对字符串正则替换

文章出处:设计前沿收集 作者:未知 发布时间:2006-09-19 收藏到QQ书签

RegReplace(str,regexStr,RepalceStr) 对str 进行正则替换

如:

htmlstr = "123<img src=""asdf.gif"" border=""0"">45<b>6</b>"
htmlstr2 = RegReplace(htmlstr,"<(.[^><]*)>","")

返回 htmlstr2 为123456

Function RegReplace(Str,PatternStr,RepStr)
 Dim NewStr,regEx
 NewStr = Str
 if isnull(NewStr) then
  RegReplace = ""
  exit function
 end if
 Set regEx = New RegExp
 regEx.IgnoreCase = True
 regEx.Global = True
 regEx.Pattern=PatternStr
 NewStr = regEx.Replace(NewStr,RepStr)
 RegReplace = NewStr
end function


Google