We Recommend

ASP.NET 3.5 Unleashed ASP.NET 3.5 Unleashed
ASP.NET 3.5 Unleashed is the most comprehensive book available on the Microsoft ASP.NET 3.5 Framework, covering all aspects of the ASP.NET 3.5 Framework--no matter how advanced.


Posted By

jc001 on 03/03/08


Tagged

regex String regular expressions manipulation


Versions (?)


Regex Functions


Published in: ASP 


Easy functions, comments in code.

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


  1. Function Regex_Match(strOriginalString, strPattern, blnIgnoreCase)
  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.  
  6. With objRegExp
  7. .Pattern = strPattern
  8. .IgnoreCase = blnIgnoreCase
  9. .Global = True
  10. End With
  11.  
  12. ereg = objRegExp.test(strOriginalString)
  13. Set objRegExp = Nothing
  14. End Function
  15.  
  16. Function Regex_Replace(strOriginalString, strPattern, strReplacement, blnIgnoreCase, blnGlobal)
  17. ' Function replaces pattern with replacement
  18. ' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive)
  19. Dim objRegExp : Set objRegExp = New RegExp
  20.  
  21. With objRegExp
  22. .Pattern = strPattern
  23. .IgnoreCase = blnIgnoreCase
  24. .Global = blnGlobal
  25. End With
  26.  
  27. ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
  28. Set objRegExp = Nothing
  29. End Function

Report this snippet 

You need to login to post a comment.