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\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)","<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
Post a Comment