From: Dipesh Batheja Date: 2008-04-15T22:36:19+09:00 Subject: Re: Reg Exp Ok let me try explain my situation a little bit. I have default route in ROR environment.rb: map.connect ':lang/:canonic/:controller/:action/:id it matches paths like: http://www.abc.com/en/acme/products/show/1 where :canonic is "acme" in this example I have a specific case where :canonic cannot be "admin" map.connect method take a key :requirements where I can specify a regex: map.connect ':lang/:canonic/:controller/:action/:id, :requirement => {:canonic => /regex/ } I need to write in the reg ex, in such a way, so that when something like: http://www.abc.com/en/admin/products/show/1 comes, it doesn't match the path. I hope this helps in explaining my situation. Jeff Schoolcraft wrote: > I'm not sure what you're going to gain from a regex if it's a specific > string and not a pattern. > > irb(main):001:0> a = "Hello World" > => "Hello World" > irb(main):002:0> !(a.include? 'Hello') > => false > irb(main):003:0> > > It seems you'd want to wrap that into a method to make the intent a > little > more obvious > > irb(main):011:0> def should_filter?(source, word) > irb(main):012:1> source.include? word > irb(main):013:1> end > => nil > irb(main):014:0> should_filter?(a, 'Hello') > > Just a thought. > > to make the regex work as in your example though, you'd do this: > irb(main):021:0> !(a =~ /hello/i) > => false > > (case insensitive matching) > > On Tue, Apr 15, 2008 at 8:59 AM, Dipesh Batheja > -- Posted via http://www.ruby-forum.com/.