U_nix$_@ has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I think its an banal bug, but would be happy if someone can help me with this.. Here` s the code:
($CON,$WWW,$HOST,$SLD,$TLD,$PORT) = $conf[1] =~ m|(http(?:s?))?(?:(?:: +//)?(w{0,3})\.{0,1})?((.*)(?:\.)(.*))(?::(\d{0,10})?)|;
Following "types" of URLs must come through:
http(s)://www.example.de
http(s)://example.de
www.example.de
example.de
and if they come with a port, it must work too:
.de:443
If a URl with port is used everything works fine. Without Port nothing works
print $CON,$WWW,$HOST,$SLD,$TLD,$PORT;
Prints following:
http(s) www example.de example de 443
if something is missing: http://example.de:80 :
http "empty" example.de example de 80 ”
Somewhere must be a little bug.
No Variable gets a value if a URL with no Port is given
I guess the reason is "?::". No ":" no match. If I change it both URLs are accepted but it does not split up the Port. The port remains at the TopLevelDomain and is joined to the host variable.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl RegEx (url explode)
by choroba (Cardinal) on Nov 01, 2012 at 22:53 UTC | |
Re: Perl RegEx (url explode)
by aitap (Curate) on Nov 02, 2012 at 18:54 UTC | |
Re: Perl RegEx (url explode)
by cnd (Acolyte) on Mar 31, 2018 at 06:12 UTC | |
Re: Perl RegEx (url explode)
by U_nix$_@ (Initiate) on Nov 01, 2012 at 23:07 UTC | |
by U_nix$_@ (Initiate) on Nov 01, 2012 at 23:20 UTC | |
by Perlbotics (Archbishop) on Nov 01, 2012 at 23:28 UTC | |
by U_nix$_@ (Initiate) on Nov 01, 2012 at 23:33 UTC |