问题描述: Return the number (count) of vowels in the given string. We will consider a, e, i, o, and u as vowels for this Kata. The input string will only consist of lower case letters and/or spaces. function getCount(str) { var vowelsCount = 0; // enter…
正则表达式对象常用方法 test() 检索字符串中指定的值.返回 true 或 false. var str="Embrace You" var r1=/you/i.test(str)//i 忽略大小写 console.log(r1)//true 支持正则表达式的String对象的方法 split() 可以将一个字符串拆分为一个数组 方法中可以传递一个正则表达式作为参数,这样方法将会根据正则表达式去拆分字符串 var str="1a2B3d4g5c6" var re…
正则相关[i不区分大小写,g匹配全部数据] var str = "Hello word! I think word is good."; 1.替换str中的word为javascript str.replace(/word/ig,'javascript'); //Hello javascript! I think javascript is good. 结果为替换后的字符串 2.判断str中是否包含word /word/ig.test(str); //true 布尔值 3.获取st…