From: "Peña, Botp" Date: 2008-04-18T13:24:38+09:00 Subject: Re: Reg Exp [mailto:list-bounce@example.com] On Behalf Of Dipesh Batheja # 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. try the ?!, this seems to negate the regex eg, the following will strictly not allow admin and case-combi like Admin. it will thus allow xadmin, radmin, administration, etc.. irb(main):044:0> /(?!^admin$).{5,5}/i =~ "admin" => nil irb(main):045:0> /(?!^admin$).{5,5}/i =~ "Admin" => nil irb(main):046:0> /(?!^admin$).{5,5}/i =~ "ADMIN" => nil irb(main):047:0> /(?!^admin$).{5,5}/i =~ "administration" => 0 irb(main):048:0> /(?!^admin$).{5,5}/i =~ "xadmin" => 0 irb(main):049:0> /(?!^admin$).{5,5}/i =~ "xadminx" => 0 irb(main):050:0> /(?!^admin$).{5,5}/i =~ "adminx" kind regards -botp