[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-20 Thread frogstarr78
Yeah, I understand what you mean. No worries. On Dec 19, 11:10 pm, AlwaysCharging wrote: > But that made me question why I couldn't just put the "/" inside of > the bracket as well.  Like why did that have to be escaped if the > period didn't.  (I guess it's because in that syntax, the forward >

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread AlwaysCharging
But that made me question why I couldn't just put the "/" inside of the bracket as well. Like why did that have to be escaped if the period didn't. (I guess it's because in that syntax, the forward slash has closure properties.) Oh well it's working now, and I escaped the . as well (\.). Thank yo

Re: [Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread maryam kamali
hello iam maryam ihave peroblem ishal go aftenon by On Sat, Dec 19, 2009 at 11:21 AM, ralu wrote: > > > On Dec 18, 11:01 pm, AlwaysCharging wrote: > > 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 > > regu

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread frogstarr78
It actually depends on where the "." is in the Regexp. In your case it is inside a Character Class "[]". So it is matching the "." character explicitly. Since \w is shorthand for the [a-zA-Z] character class. It is parsed as a character class instead of an escaped "w" character. So you could actual

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread AlwaysCharging
Yes, that did it. Thank you. No idea how I try everything and overlook the simplest solution, duh. And, Thank you to everyone else that weighed in as well, definitely some other options to look into. Side note: Anybody know why the period doesn't have to be escaped? Like just "." allows the dot

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread Alan
Use Ruby's other regexp syntax: %r{pattern} To continue your example below: validates_format_of :url, :with => %r{^[-\w_./]+$} AlwaysCharging wrote: > 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 > regu

Re: [Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread Sven Riedel
Sven Riedel wrote: > /^http:\/\/myhostname\.com\/foo$/i > > would become > > %r{http://myhostname\.com/foo}i And of course I forgot the anchors in the second example. So the correct version is: %r{^http://myhostname\.com/foo$}i -- You received this message because you are subscribed to the Go

Re: [Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread Sven Riedel
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

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread frogstarr78
Have you tried escaping them "\/"? On Dec 18, 11:01 pm, AlwaysCharging wrote: > 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_f

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-18 Thread ralu
On Dec 18, 11:01 pm, AlwaysCharging wrote: > 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\_.]