开发者

can you get me * out aaa.*.domain.com using regex?

No matter how hard I try I can't get this.. This matches the whole domain only when it's format is aaa.bbb.ccc .

^[^.]+\.[^.]+\.[^.]+$

Our domain name is static (domain.com). So this needs to select * out aaa.*.domain.com.

开发者_StackOverflow

aaa may or may not be there.

Thanks!

ps: sorry for aaa part being unclear. it's another unknown. so it is *.*1.domain.com and I only need *1 whatever comes before should be deleted, domain.com is static.


Try ([^.]+)\\.domain\\.com$ ... and $1 in your rewrite rule to pass along the match.


I believe what you want is: ^aaa.(.+).domain.com$

This matches the start of the string, followed by aaa then a dot (^aaa.) followed by a non-empty sequence of characters which you save as a variable using parenthesis, followed by a dot then domain dot com end-of-string

Use a $1 in your rewrite rule to access the bit saved with the parenthesis.

Possibly, you might want to omit the $ if it isn't the end, but you should be able to work it out from that, I think.


^(?:[^\.]*?\.)?((?:(?:[^\.\r\n]*?)\.)+)domain.com$
^aaa?((?:(?:[^\.\r\n]*?)\.)+)domain.com$

should be able to isolate .* in a group for you to use.

aaa.bbb.domain.com => bbb
aaa.domain.com => aaa
xyz.domain.com => xyz
aaa.bbb.ccc.domain.com => bbb.ccc


This ($2) will give you the second part if aaa exists, else the first part:

(aaa\.){0,1}([^.]+)(?=\.domain\.com)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜