统计某一字符或字符串在另一个字符串中出现的次数
文章目录
function strCount(str, target) {
let count = 0
if (!target) return count
while(str.match(target)) {
str = str.replace(target, '')
count++
}
return count
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论