VBScript Regular Expressions


/ Published in: ASP
Save to your folder(s)

Based on the ereg family of functions in PHP.


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.