Proposal: JavaScript String.prototype.count() Example > s = 'abc/d/efg/h' > s.count('/') 3 Other languages Java (Apache): StringUtils.countMatches Python: str.count Ruby: String#count PHP: substr_count See also Stackoverflow question seen 581,000 times.