基本概念
( ) | 标记一个子表达式的开始和结束位置。子表达式可以获取供以后使用。要匹配这些字符,请使用 \( 和 \)。 |
* | 匹配前面的子表达式零次或多次。要匹配 * 字符,请使用 \*。 |
. | 匹配除换行符 \n 之外的任何单字符。要匹配 . ,请使用 \. 。 |
解决方案
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());
参考文章
https://blog.csdn.net/leftfist/article/details/64439445
https://www.runoob.com/regexp/regexp-syntax.html
https://blog.csdn.net/zzti_erlie/article/details/89842391
http://www.cnblogs.com/mayidudu/p/5885113.html
http://www.cnblogs.com/manongxiaobing/p/9835611.html
https://blog.csdn.net/qq_38111015/article/details/80416823