Return to Snippet

Revision: 5366
at March 3, 2008 16:37 by jc001


Initial Code
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

Initial URL

                                

Initial Description
Easy functions, comments in code.

From:  http://www.ilovejackdaniels.com/asp/vbscript-regular-expressions/

Initial Title
Regex Functions

Initial Tags
regex

Initial Language
ASP