Open zivenday opened 5 years ago
function countStr(str, target) {
if (!str || target === null || target === undefined) return 0
let reg = new RegExp(`(${target})`, 'g')
var count = 0
str.replace(reg, function(match, c) {
++count
return c
})
console.log(count)
}
countStr('assssssa', 'b')
https://github.com/haizlin/fe-interview/issues/21