在線參考:/cy904159293/pv89jhpu/
/* JS查找子串*/
/**
/i(忽略大小寫)
/g(全文搜索匹配字符的所有匹配項)
/m(多行搜索)
/gi(全文搜索,忽略大小寫)
/ig(全文搜索,忽略大小寫)
*/
var str = " ABab
var reg = new RegExp("Ba "," I ");
var reg 2 =/ba/I;
console . log(str . match(reg));// [“巴”,索引:1,輸入:“ABab”]
console . log(str . match(reg 2));// [“巴”,索引:1,輸入:“ABab”]
console . log(str . match(/aa/I));// null
console.log(str.indexOf("Ba ")!= -1);//真
console.log(str.indexOf("ba ")!= -1);//假