Count how many specific characters in string

TheCarver picture TheCarver · Sep 15, 2011 · Viewed 41.5k times · Source

I have a search box.

My admin user might search for "@MG @EB dorchester".

In ASP, I need to count how many times the symbol "@" appears in the string. How is the possible?

Answer

Andrew Hare picture Andrew Hare · Sep 15, 2011

Try this:

len(yourString) - len(replace(yourString, "@", ""))