正则表达式
let regex = new RegExp()
console.log('regex',regex); /(?:)/
----------------------------------------------------
let regex = new RegExp('hello','ig')
let str = 'hello people hello world hello country hello army'
console.log(str.replace(regex, '你好'));
----------------------------------------------------
let regex = /youSay/ig
let str = 'youSay 天这么蓝 yousay 空气这么清新 YouSay 你真的好开心'
console.log(str.replace(regex, '你说'))
----------------------------------------------------
let str = '五杀超神'
let regex = /五杀/
console.log(regex.test(str))
----------------------------------------------------
let str = 'uiuiuiui'
let regex = /u/
console.log(regex.exec(str))
----------------------------------------------------
let str = '急急复急急,木兰当户织'
let regex = /急急/g
console.log(str.replace(regex, '唧唧'));
let regex = /急/g
console.log(str.match(regex))
let regex = /复/
console.log(str.split(regex))
let regex = /复/
console.log(str.search(regex));
let regex = /./
let str = '\n123'
console.log(regex.test(str))
let str = '1215204550@qq.com'
let regex = /\.c/
console.log(regex.test(str))
let regex = /[0-9]/
let str = 'abc'
console.log(regex.test(str))
let regex = /[0-9a-z]/
let str = '123zzz'
console.log(regex.test(str))
let regex = /[0-9][0-9][0-9][0-9][0-9][0-9]/
let str = '23456'
console.log(regex.test(str))
let regex = /^[a-z]/
let str = '123acc'
console.log(regex.test(str))
let regex = /m$/
let str = '1215204550@qq.com'
console.log(regex.test(str))
let regex = /\d\d\d/
let str = '123'
console.log(regex.test(str))
let regex = /\D\D\D/
let str = 'A._'
console.log(regex.test(str))
let regex = /\w\w\w\w\w\w/
let str = 'qq_com'
console.log(regex.test(str))
let regex = /\W\W\W/
let str = '@ -'
console.log(regex.test(str))
let regex = /\W\s\W/
console.log(regex.test(str))
let regex = /\b/g
let str = 'hello for world'
console.log(str.replace(regex, '你好'))
let regex = /\B/g
let str = 'hello for world'
console.log(str.replace(regex, '你好'))
let regex = /4?/
let str = '123'
console.log(regex.test(str))
let regex = /a*/
let str = 'aaaBaaaaaa'
console.log(regex.exec(str))
let regex = /\d+/
let str = '4567aaaaaaaaaaaaaa'
console.log(str.replace(regex, 'hello'))
let regex = /\d{11}/
let phone = '17393845392'
console.log(regex.test(phone))
let regex = /^http:\/\/www\.\w+(.com|.cn|.gov|.net)/
let net = 'http://www.baidu.net'
console.log(regex.test(net))
let regex = /(\d{3})(\d{4})(\d{4})/
let ipone = '17393845392'
console.log(regex.test(ipone))
console.log(RegExp.$1)
console.log(RegExp.$2)
console.log(RegExp.$3)
console.log(ipone.replace(regex, '$1****$3'))
let regex = /\d+(@qq.com|@163.com)/
let mail = '1215204550@163.com'
console.log(regex.test(mail))
console.log(RegExp.$1)
let regex = /\d{6}/
let regex = /^1[3, 5, 7 ,8 , 9]\d{9}/
let regex = /[a-z]{2,6}[0-9]{6,10}/
let password = 'wa124567'
console.log(regex.test(password))