js从字符串中提取url

1 function httpString(s) {
2     var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
3     s = s.match(reg);
4     return (s)
5 }

 

posted @ 2021-02-25 14:41  python_yue  阅读(1579)  评论(0编辑  收藏  举报