note 88252 added to function.glob
| From: | crayonviolent at phpfreaks dot com | Date: | Sat, 17 Jan 2009 08:26:14 +0000 |
| Subject: | note 88252 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149363@lists.php.net to get a copy of this message | ||
(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.
----
Server IP: 209.41.74.194
Probable Submitter: 96.35.236.175
----
Manual Page -- http://www.php.net/manual/en/function.glob.php
Edit -- https://master.php.net/note/edit/88252
Del: integrated -- https://master.php.net/note/delete/88252/integrated
Del: useless -- https://master.php.net/note/delete/88252/useless
Del: bad code -- https://master.php.net/note/delete/88252/bad+code
Del: spam -- https://master.php.net/note/delete/88252/spam
Del: non-english -- https://master.php.net/note/delete/88252/non-english
Del: in docs -- https://master.php.net/note/delete/88252/in+docs
Del: other reasons-- https://master.php.net/note/delete/88252
Reject -- https://master.php.net/note/reject/88252
Search -- https://master.php.net/manage/user-notes.php