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?
There are many ways for counting the number of occurrences of a char in a String. Let's start with a simple/naive approach: String someString = "elephant"; char someChar = 'e'; int count = 0; for (int i = 0; i < someString. length(); i++) { if (someString.
To use the function, enter =LEN(cell) in the formula bar and press Enter. In these examples, cell is the cell you want to count, such as B1. To count the characters in more than one cell, enter the formula, and then copy and paste the formula to other cells.
Python String count() The count() method returns the number of occurrences of a substring in the given string.
Tip: If you want to count the total number of a specific character in a range, you can use this formula =SUMPRODUCT(LEN(A2:A6)-LEN(SUBSTITUTE(A2:A6,B2,""))), and A2:A2 is the range you want to count the specified character from, and B2 is the character you want to count.
Try this:
len(yourString) - len(replace(yourString, "@", ""))
Response.write ubound(split(str,"@"))
is enough for counting the occurance of a specific character
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With