从给定字符串中提取 URL

Extract urls from given string

本文关键字:提取 URL 字符串      更新时间:2023-09-26
house home go https://www.monstermmorpg.com
nice hospital http://www.monstermmorpg.com 
this is incorrect url http://www.monstermmorpg.commerged 
continue

我想提取所有以http/https开头的网址

我确实尝试使用这个正则表达式,但我一无所获。

$('links').value = stringText.match("'b(?:http://|https://)'S+'b/");
    var string = "house home go https://www.monstermmorpg.com hospital "
     +" http://www.monstermmorpg.io"
     +" this is incorrect url http://www.monstermmorpg.commerged"
    .match(/'b(https?:'/'/.*?'.[a-z]{2,4}'b)/g);

只有前两个。

   ["https://www.monstermmorpg.com", "http://www.monstermmorpg.io"]