Help with regular expression

First at all sory if my english is not the best.
We have a problem in our web when a user writes a long url. The
structure of the web becomes ugly…
First, we tried to solve this poblem with CSS. We implemented something
like that:

msgforo .p {
overflow: hidden;
word-wrap: break-word;
}

but it wasn’t the solution for our problem because some words at the end
of the line repeat it in the next one. Something like that:


someone can help me with
my doubt?

becomes to:

someone can help me with with
my doubt?

We are thinking to solve this problem using regular expressions,we want
to detect the urls and turn these into a links.
With this regular expression:
(\b(https?|ftp|file)\S+|\b(www?|ftp|file)\S+) I can detect the urls (Is
checked in www.rubular.com great page to test our expressions).
But i have a big problem, I only want to turn into a link the urls what
there isn’t into <a href=“www…” and <img source=“www”. These kind of
urls must stay with no changes.

Somebody can help me? I don’t know how create a distinction between the
two kinds of urls.

Thank a lot

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