views:

20

answers:

1

i have a string that maybe contains text with links. I use these instructions for elaborate it:

message = message.gsub(/http[s]?:\/\/[^\s]+/) do |m|      
      replace_url(m)
    end

if the string is "http://www.youtube.com/watch?v=6zToqLlM8ms&playnext_from=TL&videos=qpCvM5Ocr3M&feature=sub" the instructions works.

but if the string is "hi my video is http://www.youtube.com/watch?v=6zToqLlM8ms&playnext_from=TL&videos=qpCvM5Ocr3M&feature=sub" doesn't works

why?

how can i do?

thanks

A: 

Beucase this not match a pattern. Get before url add expression to catch some crap before url.

You can also try match a regex pattern to every word. Because url is always one word separated word.

Svisstack
Anton