正则表达式

226 阅读1分钟

1.获取括号内内容

/\(([^)]*)\)/.exec(result)

2.空格分隔

'124235ewfdgdfhrtht'.toString().replace(/(.)(?=(?:.{4})+$)/g,'$1 ')

3.获取url参数

let ret = location.search.match(new RegExp('(\\?|&)' + key + '=(.*)(&|$)')) return ret && decodeURIComponent(ret[2])