Posted By

Scooter on 05/02/09


Tagged


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Who likes this?

2 people have marked this snippet as a favorite

wizard04
benrudolph


Regular Expressions


Published in: ASP 






URL: http://reusablecode.blogspot.com/2009/05/regular-expressions.html

Expand | Embed | Plain Text
  1. <%
  2. ' ASP Regular Expression Library
  3. '
  4. ' Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved.
  5. '
  6. ' This work is licensed under the Creative Commons Attribution License. To view
  7. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  8. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  9. ' 94305, USA.
  10.  
  11. ' Case-sensitive regular expression match.
  12. function ereg(pattern, inputString)
  13. dim regEx
  14.  
  15. set regEx = new RegExp
  16.  
  17. with regEx
  18. .Pattern = pattern
  19. .IgnoreCase = False
  20. .Global = True
  21. end with
  22.  
  23. ereg = regEx.test(inputString)
  24. set regEx = nothing
  25. end function
  26.  
  27. ' Case-insensitive regular expression match.
  28. function eregi(pattern, inputString)
  29. dim regEx
  30.  
  31. set regEx = new RegExp
  32.  
  33. with regEx
  34. .Pattern = pattern
  35. .IgnoreCase = True
  36. .Global = True
  37. end with
  38.  
  39. eregi = regEx.test(inputString)
  40. set regEx = nothing
  41. end function
  42.  
  43. ' Case-sensitive regular expression replacement.
  44. function ereg_replace(pattern, replacement, inputString)
  45. dim regEx
  46.  
  47. set regEx = new RegExp
  48.  
  49. with regEx
  50. .Pattern = pattern
  51. .IgnoreCase = False
  52. .Global = True
  53. end with
  54.  
  55. ereg_replace = regEx.replace(inputString, replacement)
  56. set regEx = nothing
  57. end function
  58.  
  59. ' Case-insensitive regular expression replacement.
  60. function eregi_replace(pattern, replacement, inputString)
  61. dim regEx
  62.  
  63. set regEx = new RegExp
  64.  
  65. with regEx
  66. .Pattern = pattern
  67. .IgnoreCase = True
  68. .Global = True
  69. end with
  70.  
  71. ereg_replace = regEx.replace(inputString, replacement)
  72. set regEx = nothing
  73. end function
  74.  
  75. ' Make regular expression for case insensitive match.
  76. function sql_regcase(byVal inputString)
  77. ' Change all alphabetic characters to uppercase.
  78. inputString = ucase(inputString)
  79.  
  80. ' Loop through the alphabet in ASCII. A = 65 and Z = 90.
  81. for i = 65 to 90
  82. ' The corresponding lowercase letter of the alphabet is always 32 positions ahead of the uppercase letter.
  83. inputString = replace(inputString, Chr(i), "[" & Chr(i) & Chr(i + 32) & "]"
  84. next
  85.  
  86. sql_regcase = inputString
  87. end function
  88. %>

Report this snippet 

You need to login to post a comment.

Download royalty free graphics