Ask a Question related to PERL Modules, Design and Development.
-
John Bokma #1
subdomain.domain.tld regexp?
Is there a module that can split a given host in a subdomain, domain, tld
part?
e.g.
[url]www.google.com[/url] => www google com
[url]www.google.co.uk[/url] => www google.co uk
[url]www.google.nl[/url] => www google nl
[url]www.asus.com.tw[/url] => www asus.com tw
(yup, technically the com? is probably the domain, and www a sub-sub
domain)
--
John Small Perl scripts: [url]http://johnbokma.com/perl/[/url]
Perl programmer available: [url]http://castleamber.com/[/url]
Happy Customers: [url]http://castleamber.com/testimonials.html[/url]
John Bokma Guest
-
Subdomain Connections
I am reopening a problem raised last year on this forum. When I try to edit a page in a subdomain (my-subdomain.my-domain.com/my-page.htm), it... -
subdomain problem
Hello folks... I'm using Contribute 3.11 on the Mac, and I have a problem with subdomains. I'm the admin for a local school, and I have a connection... -
New subdomain does not display cfm pages
I created 2 new subdomain on our IIS 5 server running ColdFusion 5.0 These 2 new subdomains are parsing HTML pages fine, however, they are not... -
Subdomain Experts
I want to set up users with subdomains (user.domain.tld). My DNS can be modified by me using IP, CNAME or TXT. I have shared hosting so if... -
Regexp to find the subdomain (if any) from $HTTP_HOST
I need help creating a regular expression to find the subdomain in the $HTTP_HOST variable. The domain is always in this form: www.domain.com... -
Brian McCauley #2
Re: subdomain.domain.tld regexp?
John Bokma wrote:
DNS is strictly hierachical. As far as DNS is concerned 'uk', 'co.uk',> Is there a module that can split a given host in a subdomain, domain, tld
> part?
>
> e.g.
>
> [url]www.google.com[/url] => www google com
> [url]www.google.co.uk[/url] => www google.co uk
> [url]www.google.nl[/url] => www google nl
> [url]www.asus.com.tw[/url] => www asus.com tw
>
> (yup, technically the com? is probably the domain, and www a sub-sub
> domain)
'google.co.uk' and 'www.google.co.uk' are all just domains.
You need to take a step back and consider what you really want to do. I
suspect you have no idea.
To split a dot-delimited string into a list of components:
my @components = split /\./, $domain_name;
Do you perhaps want to find the DNS zone boundries? If so why do you
think this would be helpful?
Brian McCauley Guest
-
John Bokma #3
Re: subdomain.domain.tld regexp?
Brian McCauley wrote:
Yeah I know.> John Bokma wrote:
>>>> Is there a module that can split a given host in a subdomain, domain,
>> tld part?
>>
>> e.g.
>>
>> [url]www.google.com[/url] => www google com
>> [url]www.google.co.uk[/url] => www google.co uk
>> [url]www.google.nl[/url] => www google nl
>> [url]www.asus.com.tw[/url] => www asus.com tw
>>
>> (yup, technically the com? is probably the domain, and www a sub-sub
>> domain)
> DNS is strictly hierachical. As far as DNS is concerned 'uk',
> 'co.uk', 'google.co.uk' and 'www.google.co.uk' are all just domains.
Because you don't have an idea doesn't mean I haven't one.> You need to take a step back and consider what you really want to do.
> I suspect you have no idea.
I want to get the part one can register as, say, a company.
in the uk I can't register
somename.uk
but I can register:
somename.co.uk
In nl however, I can register:
somename.nl
--
John Small Perl scripts: [url]http://johnbokma.com/perl/[/url]
Perl programmer available: [url]http://castleamber.com/[/url]
Happy Customers: [url]http://castleamber.com/testimonials.html[/url]
John Bokma Guest
-
Brian McCauley #4
Re: subdomain.domain.tld regexp?
John Bokma wrote:
No, but the fact that your OP does not convey your idea is often a good> Brian McCauley wrote:
>
>>>>John Bokma wrote:
>>
>>>>>>>Is there a module that can split a given host in a subdomain, domain,
>>>tld part?
>>>
>>>e.g.
>>>
>>>[url]www.google.com[/url] => www google com
>>>[url]www.google.co.uk[/url] => www google.co uk
>>>[url]www.google.nl[/url] => www google nl
>>>[url]www.asus.com.tw[/url] => www asus.com tw
>>>
>>>(yup, technically the com? is probably the domain, and www a sub-sub
>>>domain)
>>DNS is strictly hierachical. As far as DNS is concerned 'uk',
>>'co.uk', 'google.co.uk' and 'www.google.co.uk' are all just domains.
>
> Yeah I know.
>
>>>>You need to take a step back and consider what you really want to do.
>>I suspect you have no idea.
> Because you don't have an idea doesn't mean I haven't one.
sign that you haven't actually crystalised your idea.
This is a question about the policy of issuing subdomains under a> I want to get the part one can register as, say, a company.
domain. There may or may not be a standard way for a domain to publish
its subdomain policy. There certainly is no widely used standard.
If there were a widely used standard then there could be a Perl module
to interface to it.
You can't, but some entities can. Sufficiently few uk 2nd-LDs are> in the uk I can't register
>
> somename.uk
issued I suspect each application is considered on it's merits rather
than there being a simple algotithm.
There are also domains like ac.uk which accept registrations from a
restricted class of entities.
Someone could compose a list of domains that accept subdomain
registration from the general populace but this could simply be a plain
text file rather than a Perl module.
Note: there are situations like uk.com where both uk.com and com accept
registrations.
Brian McCauley Guest
-
Carl Corliss #5
Re: subdomain.domain.tld regexp?
@Brian McCauley: How about reading between the lines a little and providing a /helpful/ answer instead of rhetoric. It's not that hard to see that what he wants is just the domain part of a domain name and not the host part.
@John Bokma: While there is no perl module that I am aware of that will give you what you seek, you can certainly get most of the way there with regular expressions:
Cheers!,Code:foreach (qw(a.b.co.uk a.b.uk.com a.b.com b.co.uk b.uk.com b.com z.y.x.a.b.c.co.uk z.y.x.a.b.c.uk.com) ) { printf("%-19s: %s\n", $_, ($_ =~ m/ (?| # branch reset (perl 5.10+ specific), also doesn't count as a capture group (?=^[a-z][a-z0-9-]*\.[a-z]{2,3}$)(.*) # check for domain.tld or domain.tl and capture it (as $1) | (?:^[a-z][a-z0-9-]*\.)*? # skip past subdomain parts (with a non capturing group) (?| # branch reset (perl 5.10+ specific), also doesn't count as a capture group (?=[a-z][a-z0-9-]*\.[a-z]{2}\.[a-z]{2,3})(.*) # look ahead for host.uk.com or host.co.uk and capture it | (?=[a-z][a-z0-9-]*\.[a-z]{3})(.*) # look ahead for host.com and capture it ) )$ /x ? $1 : "no match")); }
--
CarlCarl Corliss Guest



Reply With Quote

