HEELPBOOK - VBScript - Regular Expression Search and Replace Functions ############################## Functions to make using regular expressions a bit easier. They're named after the respective PHP function. ########## Function to Search function ereg(strOriginalString, strPattern, varIgnoreCase) ' 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 = varIgnoreCase .Global = True end with ereg = objRegExp.test(strOriginalString) set objRegExp = nothing end function ########## Function to Replace function ereg_replace(strOriginalString, strPattern, strReplacement, varIgnoreCase) ' 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 = varIgnoreCase .Global = True end with newStr = objRegExp.replace(strOriginalString, strReplacement) ereg_replace = newStr set objRegExp = nothing end function ############ ARTICLE INFO ############# Article Month: October Article Date: 08/10/2012 Permalink: http://heelpbook.altervista.org/2012/vbscript-regular-expression-search-and-replace-functions/ Source: http://snipplr.com/view/19559/ Language: English View more articles on: http://www.heelpbook.net/ Follow us on Facebook: http://it-it.facebook.com/pages/HeelpBook/100790870008832 Follow us on Twitter: https://twitter.com/#!/HeelpBook Follow us on RSS Feed: http://feeds.feedburner.com/Heelpbook Follow us on Delicious: http://delicious.com/heelpbook Linkedin: http://it.linkedin.com/pub/stefano-maggi/27/73a/b20