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.


Ballyhoo


Posted By

Scooter on 03/12/08


Tagged

strings


Versions (?)


Count instances of one string in another


Published in: ASP 


URL: http://reusablecode.blogspot.com

Similar to the substr_count function from PHP, but with fewer options.


  1. <%
  2. ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
  3. '
  4. ' This work is licensed under the Creative Commons Attribution License. To view
  5. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  6. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  7. ' 94305, USA.
  8.  
  9. ' Count the number of occurences of one string in another.
  10. function InstrCount(haystack, needle)
  11. if needle <> "" then
  12. InstrCount = UBound(Split(haystack, needle))
  13. end if
  14. end function
  15. %>

Report this snippet 

You need to login to post a comment.