摘要: let str = 'abbbdsscc'; // match 方法返回匹配的数组 let res = str.match(/b/g); let count = !res ? 0 : res.length; console.log(count) 参考:https://zhidao.baidu.com 阅读全文
posted @ 2020-11-30 22:18 公瑾当年 阅读(4429) 评论(0) 推荐(0) 编辑
摘要: let str = '12×3÷4+6-9'; // 按照 × ÷ + - 分割 使用正则的方式分割 加号是正则的关键字,使用[+] let strArr = str.split(/×|-|÷|[+]/); console.log(strArr); // ["12", "3", "4", "6", 阅读全文
posted @ 2020-11-30 22:13 公瑾当年 阅读(8424) 评论(0) 推荐(1) 编辑