0
house home go https://www.monstermmorpg.com
nice hospital http://www.monstermmorpg.com 
this is incorrect url http://www.monstermmorpg.commerged 
continue

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

我确实尝试使用这个正则表达式,但我什么也没得到。

$('links').value = stringText.match("\b(?:http://|https://)\S+\b/");
4

1 回答 1

1
    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"] 
于 2013-07-12T14:43:02.903 回答