【Web前端】Js利用正则表达式提取字符串

来源:互联网 发布:win10win7共享网络 编辑:程序博客网 时间:2024/05/16 17:40

使用字符串replace函数(回调函数形式)配合正则表达式提取里面的股票代码

// 使用正则表达式提取URL中的股票代码var url = "http://hq.sinajs.cn/list=sh600585,sh600985,sh600586";var regx = /sh([0-9]+)/ig;url.replace(regx, function(s, value){   console.log(value);});
1 0
原创粉丝点击