in reply to regex to extract fully-qualified domain name from full URL
would do what you want, working from your above example...^(http://[^/]*)
outputs http://www.hostname.co.uk - and it should work ok with IP addresses and the http://username:password@hostname/ format, etcmy $foo = "http://www.hostname.co.uk/foo/bar"; print $foo =~ m#^(http://[^/]*)#;
andy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex to extract fully-qualified domain name from full URL
by tadman (Prior) on Mar 22, 2001 at 23:45 UTC | |
by andye (Curate) on Mar 23, 2001 at 15:15 UTC |