VBScript正则表达式搜索和替换函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VBScript正则表达式搜索和替换函数相关的知识,希望对你有一定的参考价值。
Functions to make using regular expressions a bit easier. They're named after the respective php function.
'**************************************** ' Functions to make using regular expressions a bit easier. They're named after the respective PHP function. ' ' Got these from http://www.addedbytes.com/asp/vbscript-regular-expressions/ '**************************************** 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 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
以上是关于VBScript正则表达式搜索和替换函数的主要内容,如果未能解决你的问题,请参考以下文章
Python爬虫编程思想(35):用正则表达式搜索替换和分隔字符串