note 18332 deleted from function.preg-match by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:12:51 +0000 |
| Subject: | note 18332 deleted from function.preg-match by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57392@lists.php.net to get a copy of this message | ||
Note Submitter: shecodu@webco.com.mx
----
To split a host, you can use this expresion.
preg_match("/^(.*:\/\/)?([^:\/]+):?([0-9]+)?(.*)/", $url,
$match);
list(,$proto,$host,$port,$file) = $match;
Meaning: starts with, possibly, one or more letters, followed by "://" (protocol), one or
more letters, but a colon (host), possibly a colon, followed by the posibility of one or more
numbers (port), and any number of trailing chars, (file/query).