包含URL字符串中的任何地方我要檢查,如果字符串中包含的網址使用JavaScript我得到這個代碼從谷歌檢查字符串使用JavaScript
if(new RegExp("[a-zA-Z\d]+://(\w+:\[email protected])?([a-zA-Z\d.-]+\.[A-Za-z]{2,4})(:\d+)?(/.*)?").test(status_text)) {
alert("url inside");
}
但它只適用於像"http://www.google.com"和"http://google.com"但網址它不工作"www.google.com".Also我想從字符串中提取該網址,所以我可以處理該網址。
的可能重複(http://stackoverflow.com/questions/161738/what-is-best-regular-expression-to-check-if-a-string-is-a-valid-url) – user123444555621
@ Pumbaa80:沒有我的問題有點不同,我的意見可能有純字符串,只有網址,或者文字和網址一起。 –