Posted By

DaveChild on 09/11/08


Tagged

replace regular expressions


Versions (?)

VBScript Regular Expressions


 / Published in: ASP
 

URL: http://www.addedbytes.com/asp/vbscript-regular-expressions/

Based on the ereg family of functions in PHP.

  1. function ereg(strOriginalString, strPattern, varIgnoreCase)
  2. ' Function matches pattern, returns true or false
  3. ' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive)
  4. dim objRegExp : set objRegExp = new RegExp
  5. with objRegExp
  6. .Pattern = strPattern
  7. .IgnoreCase = varIgnoreCase
  8. .Global = True
  9. end with
  10. ereg = objRegExp.test(strOriginalString)
  11. set objRegExp = nothing
  12. end function
  13.  
  14. function ereg_replace(strOriginalString, strPattern, strReplacement, varIgnoreCase)
  15. ' Function replaces pattern with replacement
  16. ' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive)
  17. dim objRegExp : set objRegExp = new RegExp
  18. with objRegExp
  19. .Pattern = strPattern
  20. .IgnoreCase = varIgnoreCase
  21. .Global = True
  22. end with
  23. ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
  24. set objRegExp = nothing
  25. end function

Report this snippet  

You need to login to post a comment.