I've just read this thred and I've got a similar question. I'm using an application helper what is use for cleaning up the HTML strings. This function replaces the \n parts to valid <br /> tags and so on...
I wanted to convert the URLs into hyperlinks, so I just inserted this into the function:
s.gsub!("/^(http|https):\/\/\S+/", "<a href='\0'>link</a>
The idea is the following:
- In the first row i replace every HTML tag (works fine)
. Nex step is to convert \n-s into <br /> tags.
For here, everything works fine. Only the last command is a "little bit wrong" - Actually it crashes my whole rails application.
The idea is to use RegEXP to find every string what starts with 'http://' or 'https://' and convert the whole string into a hyperlink, by inserting the anchor tags before and after them.
As I've wrote, the last row destroys my whole rails app. Can anyone help pls? Is the RegEXP wrong or what? (I was trying to find a similar workaround for URLs - there must be at least one... - but I haven't find anything about that. As a last hop, I dropped it here as a question for you expert guys, you'll probably know a workaround for this!
Thanks a lot
Last edited by liquid (2007-05-25 15:49:35)