note 88252 deleted from function.glob by danbrown

From: Date: Thu, 03 Dec 2009 14:14:23 +0000
Subject: note 88252 deleted from function.glob by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163538@lists.php.net to get a copy of this message
Note Submitter: crayonviolent at phpfreaks dot com ---- (continuation from previous post) glob's regex does not offer any kind of quantification of a specified character or character class or alternation. For instance, if you have the following files: a.php aa.php aaa.php ab.php abc.php b.php bc.php with pcre regex you can do ~^a+\.php$~ to return a.php aa.php aaa.php This is not possible with glob. If you are trying to do something like this, you can first narrow it down with glob, and then get exact matches with a full flavored regex engine. For example, if you wanted all of the php files in the previous list that only have one or more 'a' in it, you can do this: <?php $list = glob("a*.php"); foreach ($list as $l) { if (preg_match("~^a+\.php$~",$file)) $files[] = $l; } ?> glob also does not support lookbehinds, lookaheads, atomic groupings, capturing, or any of the 'higher level' regex functions. glob does not support 'shortkey' meta-characters like \w or \d.

« previous php.notes (#163538) next »