介绍
var content="链接:https://pan.baidu.com/s/14Ohd4jLuMWLRtqIt6eUNKg\n提取码:5dlw\n复制这段内容后打开百度网盘手机App,操作更方便哦";
var reg = /链接:(.*)/;
// https://pan.baidu.com/s/14Ohd4jLuMWLRtqIt6eUNKg
console.log(reg.exec(content)[1].trim());
var reg1 = /提取码:(.*)/;
// 5dlw
console.log(reg1.exec(content)[1].trim());
测试正则表达式
打开浏览器console框输入类似如下内容即可
其中//中为正则表达式
test函数里面是字符串
/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test("139@gmail.com");
参考博客
[1]https://blog.csdn.net/leftfist/article/details/64439445
[2]http://www.cnblogs.com/mayidudu/p/5885113.html
[3]http://www.cnblogs.com/manongxiaobing/p/9835611.html
[4]https://blog.csdn.net/qq_38111015/article/details/80416823