How can I check if a string is a valid URL?
For example:
http://hello.it => yes http:||bra.ziz, => no
If this is a valid URL
In general,
/^#{URI::regexp}$/
will work well, but if you only want to match http or https, you can pass those in as options to the method:
http
https
/^#{URI::regexp(%w(http https))}$/
That tends to work a little better, if you want to reject protocols like ftp://.
ftp://