Extract urls from given string
本问题已经有最佳答案,请猛点这里访问。
1 2 3 4 | 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
我确实尝试过使用这个regex,但是我什么也没得到。
1 | $('links').value = stringText.match("\b(?:http://|https://)\S+\b/"); |
1 2 3 4 | 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); |
第一个/只。
1 | ["https://www.monstermmorpg.com","http://www.monstermmorpg.io"] |