Count the number of occurences of a character in a string in Javascript
10:46 AM
If you want to count that how many time a string is appearing in a big string the you can count it by Javascript.
I've made a prototype function for this :
String.prototype.count=function(s1) {
return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length;
};
0 comments