格式:
RegExp_Replace(ByVal str,ByVal patrn, ByVal replStr)
參數:
str:原始字符串
patrn:正則表達式
replStr:替換的目標字符串
代碼:
Function RegExp_Replace(ByVal str,ByVal patrn, ByVal replStr)
Dim regEx, str1 ' 建立變量。
Set regEx = New RegExp ' 建立正則表達式。
regEx.Pattern = patrn ' 設置模式。
regEx.IgnoreCase = True ' 設置是否區分大小寫。
RegExp_Replace = regEx.Replace(str, replStr) ' 作替換。
End Function
應用:
response.Write RegExp_Replace("哈士奇 123","\d+", "藍貓")
返回:哈士奇 藍貓