I need to count the number of occurrences of a character in a string.
For example, suppose my string contains:
var mainStr = \"str1,str2,str3,str4\";
What about string.split(desiredCharecter).length-1
Example:
var str = "hellow how is life"; var len = str.split("h").length-1; will give count 2 for character "h" in the above string;