/ Published in: ASP
Easy functions, comments in code.
From: http://www.ilovejackdaniels.com/asp/vbscript-regular-expressions/
From: http://www.ilovejackdaniels.com/asp/vbscript-regular-expressions/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Function Regex_Match(strOriginalString, strPattern, blnIgnoreCase) ' Function matches pattern, returns true or false ' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive) Dim objRegExp : Set objRegExp = New RegExp With objRegExp .Pattern = strPattern .IgnoreCase = blnIgnoreCase .Global = True End With ereg = objRegExp.test(strOriginalString) Set objRegExp = Nothing End Function Function Regex_Replace(strOriginalString, strPattern, strReplacement, blnIgnoreCase, blnGlobal) ' Function replaces pattern with replacement ' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive) Dim objRegExp : Set objRegExp = New RegExp With objRegExp .Pattern = strPattern .IgnoreCase = blnIgnoreCase .Global = blnGlobal End With ereg_replace = objRegExp.replace(strOriginalString, strReplacement) Set objRegExp = Nothing End Function