Topic: simple text replacement question (solved)

I have a textfield where users enter URLs at http://harilo.com/shop.  Unfortunately we're getting a lot of submissions that are like http://http://example.com instead of http://example.com

I'm not very good with regexp - is there an easy way to fix these URLs?  basically a function that does this:

fixurl("http://http://example.com") => "http://example.com"
fixurl("htp://example.com") => "http://example.com"

Last edited by sthapit (2010-11-02 22:48:48)

Re: simple text replacement question (solved)

url = "http://http://example.com"
regex = /\/\/http:/
fixed = url.gsub(regex, '')
puts fixed