shaolin_gungfu has asked for the wisdom of the Perl Monks concerning the following question:
Hi fellow monks,
Sorry to ask such a simple question, but I never was any good at regular expressions! :-)
Okay, I have a sub routine like so
# takes a url as input and returns the domain<br/> sub getDomain() my ($url) = shift; $url =~m#^(http://.+?/)(.*)#i; return $1; }
This simple function just takes an address such as http://www.perlmonks.com/index.pl?whatever and turns it into http://www.perlmonks.com/
It seems to work but I also want to strip out any possible port number which might be attached to the URL, i.e. http://www.perlmonks.org:8080/index.pl
Can anyone help me with this one?
Many thanks, Tom
Added code tags - dvergin 2002-04-29
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression Question
by Juerd (Abbot) on Apr 29, 2002 at 19:13 UTC | |
|
Re: Regular Expression Question
by thelenm (Vicar) on Apr 29, 2002 at 19:24 UTC | |
by shaolin_gungfu (Novice) on Apr 29, 2002 at 19:41 UTC | |
|
Re: Regular Expression Question
by boo_radley (Parson) on Apr 29, 2002 at 19:19 UTC |