Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Extracting a domain name from a url

by ministry (Scribe)
on Oct 16, 2006 at 01:10 UTC ( #578421=note: print w/replies, xml ) Need Help??


in reply to Re^2: Extracting a domain name from a url
in thread Extracting a domain name from a url

This one is one I've been using in production for a while, and seems to hold up well:

my $url="http://proxy.aol.com:8080/login"; my($host)=$url=~/http:\/\/([^\/]+)/;

word!
-Ev

Update: Sorry, I'm a moe - I forgot to add the point of this post in my example!

Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.

Replies are listed 'Best First'.
Re^4: Extracting a domain name from a url
by ikegami (Patriarch) on Oct 16, 2006 at 01:49 UTC

    You code fails with the input you gave it. Furthermore, it doesn't work with the other example in the post to which you replied either.

    http://proxy.aol.com:8080/ gives proxy.aol.com:8080 instead of proxy.aol.com.

    http://user:pass@yahoo.com/login gives user:pass@yahoo.com instead of yahoo.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://578421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2023-06-08 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?