4 lines
136 B
JavaScript
4 lines
136 B
JavaScript
function countSubstring(str, subStr) {
|
|
var matches = str.match(new RegExp(subStr, "g"));
|
|
return matches ? matches.length : 0;
|
|
}
|