disallow some domain names, allow others
For example there are URLs http://www.subdomain1.domain.com.uk and http://www.subdomain2.domain.uk, from these URLs I need to extract only the name subdomain1 or subdomain2.
But if I receive http://www.subdomain3.co.uk or http://www.subdomain4.com I need to get the whole URL like subdomain3.co.uk or subdomain4.com.
My expres开发者_运维知识库sion: ^http:\/\/(?:www\.)?((?!SubdomainToNegate|www).*)((?!\.domain\.com\.uk|\.domain\.uk).*)$
Expression catches whole URL.
My situation is shown better over there: http://www.rubular.com/r/B1iOUoUq33
^http:\/\/(?:www\.)?((?!SubdomainToNegate|www)[^\.]*)((?!\.domain\.com\.uk|\.domain\.uk).*)$
difference is this
(?!SubdomainToNegate|www)[^\.]*
instead of this
(?!SubdomainToNegate|www)\.*
finally found solution:
http:\/\/(?:www\.)?((?:(?!domain.com.uk|domain.uk)[^\s.]+)(?:\.(?!domain.com.uk|domain.uk)[^\s.]+)*)
精彩评论