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/");
答案 0 :(得分: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"]