使用正则表达是的字符串的三个API正则表达式
//(1)replace基础用法 var str = "welcome to my home" str = str.replace(/m/g,'x') console.log(str)//welcoxe to xy hoxe
//(2)replace进阶用法 var str = "welcome to my home" str = str.replace(/\b(\w)|\s(\w)/g,(val)=>{ console.log(val) })
//(1)search的用法 var str = "hello world" c = str.search('h') console.log(c)//0 //(2)支持正则的用法 c = str.search(/o/g) console.log(c)//4
//(1)match的正则用法 var str = "who am i,i don't konw" arr = str.match(/k[\w]+w/g) console.log(arr)//['konw'] //(2)match的普通用法 var str = "tom is a good boy" lon = str.match('tom') console.log(lon)//[ 'tom', index: 0, input: 'tom is a good boy' ] //若是匹配不到值返回null //(3)match的进阶用法
正则的进阶知识数组
普通用法闭包
var str = "hello" arr = str.split('') console.log(arr)//['h','e','l','l','o']
正则用法app
var str = "hello world" arr = str.split(/\s/g) console.log(arr)
严格模式:函数
严格模式的实现this
ES5的对象保护code
单个属性保护对象
对象结构的保护继承
属性的分类原型链
替换this的三种方式
数组API: