Wednesday, 6 December 2017

javascript - How to find if a text contains url string

itemprop="text">

How can I find if text contains a url
string. I mean if I
have




Sometexthttp://daasddas
some text


I want
rel="nofollow">http://daasddas to be achored or maked as a
link wit javascript


itemprop="text">
class="normal">Answer




 function
replaceURLWithHTMLLinks(text)
{
var exp =
/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;

return text.replace(exp,"$1");


}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...