SyntaxFix
Write A Post
Hire A Developer
Questions
You can use match to define such function:
match
String.prototype.count = function(search) { var m = this.match(new RegExp(search.toString().replace(/(?=[.\\+*?[^\]$(){}\|])/g, "\\"), "g")); return m ? m.length:0; }