views:

59

answers:

4

Hi,

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.

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.

+1  A: 

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

scribble
+1  A: 

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.

McPherrinM
+1  A: 

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

(aaa\.){0,1}([^.]+)(?=\.domain\.com)
ops - misplaced the '.'
+1  A: 
^(?:[^\.]*?\.)?((?:(?:[^\.\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
VonC