note 24197 modified in function.preg-match by jmcastagnetto

From: Date: Fri, 09 Aug 2002 21:32:59 +0000
Subject: note 24197 modified in function.preg-match by jmcastagnetto
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-34632@lists.php.net to get a copy of this message
[Editor's note: parse_url() will be simpler and faster] Mr Ravis above's expression works great, but he left out one more possible part of a url. The anchor, like what follows a # sign at the very end. This includes it: preg_match("/^((.*?):\/\/)?(([^:]*): ([^@]*)@)?([^\/:]*)(:([^\/]*))? ([^\?#]*\/?)?(\?([^?#]*))?(#(.*))?$/", $oURL->url, $aURL); list(,, $sProtocol,, $sUsername, $sPassword, $sHost,, $iPort, $sPath,, $sQuery,, $sAnchor) = $aURL; --was-- Mr Ravis above's expression works great, but he left out one more possible part of a url. The anchor, like what follows a # sign at the very end. This includes it: preg_match("/^((.*?):\/\/)?(([^:]*): ([^@]*)@)?([^\/:]*)(:([^\/]*))? ([^\?#]*\/?)?(\?([^?#]*))?(#(.*))?$/", $oURL->url, $aURL); list(,, $sProtocol,, $sUsername, $sPassword, $sHost,, $iPort, $sPath,, $sQuery,, $sAnchor) = $aURL; http://www.php.net/manual/en/function.preg-match.php

« previous php.notes (#34632) next »