#10935
Stefan
Participant

 
 
I have searched for an good regex to match url.
An basic for an script could be:

//Text to parse for URL:
selText = document.selection.text;
//
//
//Show matched URLs:
vURLs = findUrls(selText);
alert(vURLs);
//
//
//Open matched URLs:
vURLs = findUrls(selText);
openUrls();
function findUrls(searchText){
// gruber revised expression - http://rodneyrehm.de/t/url-regex.html
var regex= /b((?:[a-z][w-]+:(?:/{1,3}|[a-z0-9\%])|wwwd{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/)(?:[^s()<>]+|(([^s()<>]+|(([^s()<>]+)))*))+(?:(([^s()<>]+|(([^s()<>]+)))*)|[^s`!()[]{};:'".,<>?«»“”‘’]))/ig;
result= searchText.match(regex);
if(result){return result.join("rn");}else{return false;}
}
function openUrls(vURLS){
var ie = new ActiveXObject("InternetExplorer.Application");
ie.Visible = true;
arr = vURLs.split("rn");
for(i=0,E=arr.length; i<E; i++){
vURL = arr[i];
ie.Navigate(vURL);
pause(1000);

if(i==3) quit(); // for debugging only
}
}
function pause(ms) {
ms += new Date().getTime();
while (new Date() < ms){}
}

This will open every url in IE but in same tab. Use History back.

You may want to find a solution to open each url in a new tab.

You can utilize other browsers maybe by using a code like:
var wsh = new ActiveXObject(“WScript.Shell”);
wsh.run(“notepad.exe”, 1, True);