常用的几个正则表达式

91 阅读1分钟

replace

var date = '2018-5-23';
console.log(date.replace(/-/g,'/')); // 2018/5/23

match

var s = 'hello world';
console.log(s.match(/o/g)); //["o", "o"]