Scanning for links

I’m trying to scan some text to find any thing that has an http:// and
convert it into a link, if it does not allready have and anchor on it.
excuse my beginner aproch but what I’ve been doing is converting the
string into an array and looking for anything that starts with http://
and apending and to it. I cant help but think I’m
going around the long with this by converting it into an array.

You might want to look into hpricot:
http://code.whytheluckystiff.net/hpricot/ I’ve found it useful for
things
like this.

RSL

On 1/21/07, Phil C. [email protected] wrote:

I’m trying to scan some text to find any thing that has an http:// and
convert it into a link, if it does not allready have and anchor on it.
excuse my beginner aproch but what I’ve been doing is converting the
string into an array and looking for anything that starts with http://
and apending and to it. I cant help but think I’m
going around the long with this by converting it into an array.

Have you looked at the auto_link Rails helper method?

http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M000621


Chris W.
http://errtheblog.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs