Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Wrap URL's with HREF Tags (Search/Replace)

  •  07-31-2007, 9:00 AM

    Wrap URL's with HREF Tags (Search/Replace)

    Hello. I am have an application in Ruby on Rails. I need help with the following regular expression to find URL's contained anywhere in posted text and wrap them with <a href="URL">link</a> parameters so that they link in HTML. Two examples are below:

    Check out http://www.xyz.com  =>  Check out <a href="http://www.xyz.com">link</a>

     and

    Check out www.xyz.com  =>  Check out <a href="http://www.xyz.com">link</a>

    In the first example, the posting may contain http:// or https://. In the second example, the URL may just be a www. domain. The regular expression should handle both instances. I am at a loss... ;-(

    Filed under: ,
View Complete Thread