js中字符串支持正则表达式的方法
设一个字符串
var myName = "fangming";
则支持正则表达式的方法有:split(分割),replace(替换),search(查找),match(元素参数的数组)
console.log(myName.split(/N/i));
console.log(myName.replace(/G/i,"a"));
console.log(myName.search(/N/i));
console.log(myName.match(/I/i));
设一个字符串
var myName = "fangming";
则支持正则表达式的方法有:split(分割),replace(替换),search(查找),match(元素参数的数组)
console.log(myName.split(/N/i));
console.log(myName.replace(/G/i,"a"));
console.log(myName.search(/N/i));
console.log(myName.match(/I/i));