Regular expression: How do I allow forward slashes?

AlwaysCharging
Sat, 19 Dec 2009 07:01:32 -0000

In my app, I allow users to submit urls.  They (of course) need the
ability to submit urls with a forward slash, "/", but whats the
regular expression to allow them to do that?

I currently use:

validates_format_of :url, :with => /^[-\w\_.]+$/i

to only allow alphanumerics, dashes, underscores, and dots to prevent
cross site scripting when I later reconstruct these urls, but I can''t
figure out how to allow "/" as well.

Any ideas?