Re: Re: Regular expression: How do I allow forward slashes?

Sven Riedel
Sat, 19 Dec 2009 09:14:19 -0000

frogstarr78 wrote:
> Have you tried escaping them "\/"?
Another way would be to use %r, that way you can avoid the leaning
toothpick syndrome alltogether;

/^http:\/\/myhostname\.com\/foo$/i

would become

%r{http://myhostname\.com/foo}i

But before you start piecing your own regexp together have a look at
the regexp patterns in the URI::REGEXP::PATTERN module (in your ruby lib
directory under uri/common.rb). Could save you some work depending on
what and how you want to validate.

Sven