perl --
What an amazing coincidence ... Your parents named you in an idiosyncratic
way which, amazingly, matches the language about which you now ask a question!
...and then perl said...
%
% Please help me parse this www.mydomain.com to just mydomain.com
...
You've seen the replies noting tha
On Tue, 2003-09-02 at 12:54, perl wrote:
> Please help me parse this www.mydomain.com to just mydomain.com
>
> Below are some scenarios in which all I want is the last two values,
> mydomain.com :
>
> mydomain.com = mydomain.com
> www.yourdomain.com = yourdomain.com
> www.station.fire.org = fi
Something like this should work...
my $domain = 'www.station.fire.org';
if ($domain =~ /([^\.]+\.[^\.]+)$/) {
print "$1\n";
}
else {
print "Failed to find domain\n";
}
This is very lenient in the matching, so it should match all valid domain
names as well as a lot of invalid ones. If th