c# - Check if URL in a string and return an HTML link to it -


okay i'm struggling bit here, have function gets facebook rss feeds, want string returns contain <a href = "">link</a> there urls.

any ideas of how this?

you can use regex expression find url, , make html link:

yourstring = regex.replace(yourstring,                 @"((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?)","<a href='$1'>$1</a>"); 

this replace every link <a href = "the_link">the_link</a>

for example, if yourstring contains this:

hello, text. please visit website @ http://www.google.com 

then yourstring contain this, after regex.replace:

hello, text. please visit website @ <a href="http://www.google.com">http://www.google.com</a> 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -