需求大致为匹配字符串中的url,可能是文档中出现的链接、位置不确定的带有url的字符串
const reg= /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
let result = value.match(reg);
//得到的result是一个数组
['https://www.baidu.com', 'https://www.google.com.hk/']
需求大致为匹配字符串中的url,可能是文档中出现的链接、位置不确定的带有url的字符串
const reg= /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
let result = value.match(reg);
//得到的result是一个数组
['https://www.baidu.com', 'https://www.google.com.hk/']