The use of the negative gaze proposed by edgerunner and George is great.
In principle, the template will be:
constrain :subdomain => /^(?!signup\Z|api\Z)(\w+)/ do resources :whatever end
This is the same as George’s sentence, but I changed \b to \Z - changing from the word boundary to the end of the input line itself (as noted in my comment on George’s answer).
Here are a bunch of test cases showing the difference:
irb(main):001:0> re = /^(?!www\b)(\w+)/ => /^(?!www\b)(\w+)/ irb(main):003:0> re =~ "www" => nil irb(main):004:0> re =~ "wwwi" => 0 irb(main):005:0> re =~ "iwwwi" => 0 irb(main):006:0> re =~ "ww-i" => 0 irb(main):007:0> re =~ "www-x" => nil irb(main):009:0> re2 = /^(?!www\Z)(\w+)/ => /^(?!www\Z)(\w+)/ irb(main):010:0> re2 =~ "www" => nil irb(main):011:0> re2 =~ "wwwi" => 0 irb(main):012:0> re2 =~ "ww" => 0 irb(main):013:0> re2 =~ "www-x" => 0
source share