基本上,用户可以将我的音乐应用程序映射到以下其中一个位置:
{subdomain}.{domain}.localhost
{domain}.localhost
localhost
基本上,即使用户在localhost
访问,我也需要在正则表达式{domain}.localhost
或{subdomain}.{domain}.localhost
中进行提取。有点失去了正则表达式。
所以:
mymusic.homemusic.localhost --> homemusic.localhost
homemusic.localhost --> homemusic.localhost
localhost --> localhost
编辑:我正在使用#!/ bin / sh
答案 0 :(得分:0)
在一些正则表达式之后,我得到了一个简单的答案:
[\w-]+\.?(localhost)?$
[\w-]
匹配任何字词,包括-
。+
多次。\.
匹配.
?
如果有。(localhost)
匹配该字词?
如果有。$
有很多限制性选项(如果用户输入rubish垃圾),但这对我有用。