Forum Moderators: open

Message Too Old, No Replies

Count occurrences of a word in a string

         

wingnut

7:26 pm on Feb 7, 2006 (gmt 0)

10+ Year Member



Can anyone point me to some vbscript that will search for a word in a string and return the number of times it appears? It will be used within an asp page.

TIA

Andrew

mattglet

8:22 pm on Feb 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think the easiest way to do this would be to create a RegExp object, and execute the pattern against your string. You can then count the number of matches found, and go from there.

wingnut

10:05 pm on Feb 7, 2006 (gmt 0)

10+ Year Member



Yep thats it, found an example at [authors.aspalliance.com...]

Thanks