Convert URL text to a link

March 31, 2011

Today seems to be the day for posting useful stuff on the blog. Actually, it’s just so I can quickly useful find bits of code I might need again.

So I’ve a got a web page that displays some text a user has entered that may contain URLs and I’d like them to be displayed as actual hyperlinks.

 

public string ConvertUrlsToLinks(string msg)
{
string regex = @"((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])";
Regex r = new Regex(regex, RegexOptions.IgnoreCase);
return r.Replace(msg, "$1").Replace("href=\"www", "href=\"http://www");
}

 

Advertisements

41 Responses to “Convert URL text to a link”


  1. Hello to every body, it’s my first pay a visit of this website; this website consists of remarkable and actually fine information designed for visitors.


  2. Hello to every body, it’s my first visit of this blog; this blog includes amazing and genuinely fine material for visitors.

  3. Clara Says:

    I every time used to study article in news papers but now as I am a user of internet so from
    now I am using net for posts, thanks to web.

  4. click here Says:

    I’m truly enjoying the design and layout of your blog. It’s a very easy on the eyes
    which makes it much more pleasant for me to
    come here and visit more often. Did you hire out a
    developer to create your theme? Great work!

  5. Jacki Says:

    Quality content is the crucial to invite the users to visit the web site, that’s what this site is providing.


  6. Hello there I am so happy I found your site, I really found you by mistake, while I was searching on Digg for something else,
    Anyhow I am here now and would just like to say thank you for
    a tremendous post and a all round thrilling blog (I also love the theme/design),
    I don’t have time to browse it all at the moment but I have bookmarked it
    and also added in your RSS feeds, so when I have time
    I will be back to read a great deal more, Please do keep up
    the fantastic work.


  7. Definitely believe that which you stated. Your favorite reason seemed
    to be on the web the simplest thing to be aware of. I say to you, I certainly get annoyed while people consider worries that they just don’t know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people can take a signal. Will likely be back to get more. Thanks


  8. Very good information. Lucky me I discovered your site by accident (stumbleupon).
    I’ve book-marked it for later!

  9. Peers Group Says:

    Have you ever considered about including a little bit more than just your
    articles? I mean, what you say is valuable and all.
    However think about if you added some great photos or videos to give your posts more, “pop”!
    Your content is excellent but with images and videos,
    this website could certainly be one of the most beneficial in its field.
    Excellent blog!


  10. Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too magnificent.

    I actually like what you’ve acquired here, certainly like what you’re stating and the way in which you say it.
    You make it enjoyable and you still care for to keep it wise.
    I can’t wait to read much more from you. This is actually a great web site.

  11. Ashlee Says:

    Hello I am so thrilled I found your webpage, I really found you
    by accident, while I was searching on Google for something else, Anyhow I am
    here now and would just like to say thanks a lot for a tremendous post and a all round interesting blog (I also
    love the theme/design), I don’t have time to read through it all at the moment but I have saved it and also included your RSS feeds, so when I have time I will be back to read more, Please do keep up the excellent job.


  12. I just could not go away your site prior to suggesting that I
    really loved the usual info an individual provide in your guests?
    Is going to be again regularly to check up on new posts


  13. Hello would you mind letting me know which web host you’re utilizing? I’ve
    loaded your blog in 3 completely different internet browsers
    and I must say this blog loads a lot faster then most.

    Can you suggest a good internet hosting provider at a
    honest price? Kudos, I appreciate it!


  14. Good day I am so grateful I found your blog, I really found you by accident, while I was
    browsing on Digg for something else, Anyways I am here
    now and would just like to say thank you for a remarkable post and a all round entertaining
    blog (I also love the theme/design), I don’t have time to
    read through it all at the minute but I have saved it and also included
    your RSS feeds, so when I have time I will be back to
    read a great deal more, Please do keep up the fantastic work.


  15. There is certainly a great deal to learn about this issue.
    I like all of the points you have made.


  16. At present every day we hear and read about burglaries and shoplifting in daily
    news papers. Power the connection, turn on the cameras, monitor
    and DVR respectively. Since CCTV Camera Systems are very complicated, it is best
    to hire a CCTV Installers.


  17. With most people feeling insecure about their homes,
    office and their belongings or possessions,
    whether movable or immovable, there is a dire need to have at least one of these systems installed so that
    at least some sense of relief can be achieved by them. Even in the home they are becoming a favourite, even over traditional intruder alarms.
    It has disadvantages but as you know nothing is perfect.

  18. Billy Says:

    You can have a provisional patent which allows you to be the sole owner of
    a certain invention for a short period of time.
    In case of patent services, an inventors notebook can have immense importance.
    A truly good patent attorney will not only provide you with this information but help you understand
    why your item is too similar to one that is in existence.

  19. Sterling Says:

    We are a group of volunteers and opening a new scheme in our community.

    Your web site offered us with valuable information to work on.
    You have done an impressive job and our entire community will be grateful to you.


  20. property management boise idaho is a career profession. Paint your Front Door and Mailbox!
    Be careful and think smart but quickly. What don’t they do? If the maintenance fee charged by these agents which may vary upon the type of property you have is very crucial. The efficient running of a property manager’s estimate.
    This is due to a person’s limp, he might be required to replace batteries in the new 10-year lithium battery equipped alarms.


  21. Being an investment property elsewhere. Our Charlotte apex property management
    team often takes over management of a corporate real estate portfolio to include
    single and multi-luxury, high end residential homes. They manage properties
    including: apartments, flats, penthouses, luxurious apex
    property management flats and villas for sale in Dubai is the most important thing about it is to
    follow the rules for the perfect program that simply doesnt exist.
    Nothing is as good as we have seen in 2011.


  22. We stumbled over here by a different web address and thought
    I should check things out. I like what I see so i am just following you.
    Look forward to looking over your web page again.

  23. rogwiki.de Says:

    Lifeprint Health Center Owners Select Plaza for Services on
    81, 875 SF BuildingVancouver-based Talia Jevan Properties has selected Plaza
    Companies to provide leasing, ami property management
    and construction services for a wide client base.
    In 2004 and 2005, one of the best the city has to offer. Together, LLC
    ami property management and participating retailers will cultivate quality
    client relationships and communities that bind each other through loyalty.

  24. Hershel Says:

    Audio samples and music loops of sound library webpage can be utilized
    just like a foundation. The fourth and five dimensions are regarded with high favor and have higher perfection ability.
    Because Leapster Games are able to share so that it saves major if you are buying tablets for siblings.


  25. I used to be recommended this website by my cousin. I’m no longer sure whether this submit is written through him as nobody else recognise such targeted approximately my trouble. You’re
    wonderful! Thanks!


  26. My spouse and I stumbled over here coming from a different web page and thought I should check things out.
    I like what I see so i am just following you.
    Look forward to looking over your web page for a
    second time.


  27. I have to thank you for the efforts you’ve put in penning this website. I’m hoping to view the same high-grade blog posts from you later on
    as well. In fact, your creative writing abilities has inspired me to get my own, personal website now 😉

  28. Cole Says:

    I’m not that much of a online reader to be honest but your blogs really nice, keep it up!
    I’ll go ahead and bookmark your website to come back later on. All the best

  29. Jean Says:

    I’m curious to find out what blog system you happen to be using? I’m experiencing
    some small security issues with my latest site and I would like to find something more safeguarded.

    Do you have any suggestions?


  30. Neat blog! Is your theme custom made or did you download it from somewhere?
    A design like yours with a few simple tweeks would really make my blog
    shine. Please let me know where you got your design.
    Thanks a lot


  31. Appreciation to my father who stated to me about this website, this weblog
    is genuinely amazing.


  32. I enjoy what you guys are up too. This kind of clever work
    and coverage! Keep up the terrific works guys I’ve included
    you guys to my blogroll.

  33. Harold Says:

    I blog quite often and I truly thank you for your content.
    This great article has truly peaked my interest.
    I’m going to take a note of your website and keep checking for new details about once per week.
    I opted in for your RSS feed too.


  34. This is very interesting, You’re a very skilled blogger.
    I’ve joined your rss feed and look forward to seeking
    more of your excellent post. Also, I have shared your website in my
    social networks!


  35. Thailand government is usually taking considerable measures in
    promoting the trade for profits. Complete abdominoplasty usually takes two to five hours, depending upon the extent of the work needed.
    If you smoke while recovering then the incisions
    may not heal properly and become visible.


  36. I like the helpful info you provide in your articles.
    I will bookmark your weblog and check again here frequently.
    I’m quite certain I’ll learn many new stuff right here!

    Best of luck for the next!


  37. Hello There. I discovered your blog using msn. That is an extremely neatly
    written article. I will be sure to bookmark it and
    return to read extra of your helpful info. Thank you for the post.
    I’ll certainly comeback.


  38. Nice weblog right here! Additionally your web
    site rather a lot up very fast! What host are
    you the usage of? Can I get your affiliate link for your host?

    I desire my website loaded up as fast as yours lol


  39. Greetings from Ohio! I’m bored at work so
    I decided to check out your site on my iphone during lunch break.
    I enjoy the info you present here and can’t wait
    to take a look when I get home. I’m amazed at how fast your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyways, awesome blog!


  40. Hello my family member! I wish to say that this post is amazing, great written and include almost all
    important infos. I would like to look more posts like
    this .

  41. акции Says:

    I pay a quick visit daily some blogs and sites to read content, except this
    weblog presents feature based posts.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: