1、选择

  1. | 选择(或)
  2. var str = "你去哪里,他在..."
  3. //var reg = /[你去他在]/g
  4. var reg = /你去|他在/g
  5. console.log(str.replace(reg,"*"));//**哪里,**...

2、分组

  1. () 分组
  2. var url = "http://www.baidu.com"
  3. var https = "https://www.baidu.com"
  4. var reg = /(http|https):\/\/www\.baidu\.com/
  5. console.log(reg.test(https));//true