正規表現の使用は初めてです。次のようなすべてのサブドメインを受け入れる必要があります。
something.mysite.com
something2.mysite.com
anotherthing.mysite.com
次のようなことをしたい場合、どのような正規表現をそこに置くことができますか:
rack_env['SERVER_NAME'].match <regex>
ここでは正規表現を使用しないでください。行く方法は次のとおりです。
rack_env['SERVER_NAME'].end_with?(".mysite.com")
の線に沿った何かが\.mysite\.com$
機能するはずです。http://rubular.comは、正規表現をテストするための優れたリソースです。
[a-zA-Z0-9]+\.[a-z]+\.com
something.mysite.com //ok
something2.mysite.com //ok
anotherthing.mysite.com //ok
something2mysite.com //not ok
anotherthing.mysitecom //not ok
しかし、それは危険です。
変更されているのがサブドメインだけの場合は、次を使用できます。
/\w+\.mysite\.com/