Hi im has text containing some links wrapped inside text ...
I want a regular expression (I use javascript) that can parse text and return an array of links ...
for example, for text ...
http:
testing
http:
regex will parse the text and return an array of links
arr[0] = "http://www.youtube.com/watch?v=-LiPMxFBLZY"
arr[1] = "http://www.youtube.com/watch?v=Q3-l22b_Qg8&feature=related"
I am trying to do this with code ...
var ytre =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig ;
var matches = new Array();
matches = ytre.exec(text);
var jm;
if (matches !=null )
{
for (jm=0; jm<matches.length; jm++)
{
console.log(matches[jm]);
}
}
but does not return the corresponding results ...
please, help
thank
source
share