Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #11475

Re: glob patterns

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Date Sun, 20 Oct 2013 14:50:08 +0200
From Luuk <luuk@invalid.lan>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1
MIME-Version 1.0
Newsgroups comp.lang.php
Subject Re: glob patterns
References <l3vnt7$vmi$1@news.albasani.net>
In-Reply-To <l3vnt7$vmi$1@news.albasani.net>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Message-ID <050dja-1bv.ln1@luuk.invalid.lan> (permalink)
Lines 53
NNTP-Posting-Host 2001:980:9089:1:91b8:5eaf:bac8:b68e
X-Trace 1382273701 news.xs4all.nl 15864 [2001:980:9089:1:91b8:5eaf:bac8:b68e]:46989
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.php:11475

Show key headers only | View raw


On 20-10-2013 06:58, j wrote:
>    I don't understand when to use {},[] or () in php glob matching
>
> I want to match one or more numbers, either an a,w or h, a dash and then
> a string.
>
> 120a-some_string or 1400w-some_string or 7h-some_string...
>
> Is it:
>
> glob('+{0-9}@{a,h,w}-some_string,GLOB_BRACE);
>
> or is it?:
>
> glob('+[0-9]@[ahw]-some_string');
>
> or something else?
>
> Jeff
>
>

 > ls -l *some_string
-rw-r--r-- 1 luuk users 0 Oct 20 14:45 120a-some_string
-rw-r--r-- 1 luuk users 0 Oct 20 14:45 1400w-some_string
-rw-r--r-- 1 luuk users 0 Oct 20 14:45 7h-some_string
 > php -r " print_r(glob('+[0-9]@[ahw]-some_string'));  "
Array
(
)
 > php -r " print_r(glob('+{0-9}@{a,h,w}-some_string',GLOB_BRACE));  "
Array
(
)
 > php -r " print_r(glob('*-some_string')); "
Array
(
     [0] => 120a-some_string
     [1] => 1400w-some_string
     [2] => 7h-some_string
)
 >


i would go for:
 > php -r " print_r(glob('[0-9]*[awh]-some_string')); "
Array
(
     [0] => 120a-some_string
     [1] => 1400w-some_string
     [2] => 7h-some_string
)

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

glob patterns j <mung_me@att.net> - 2013-10-20 00:58 -0400
  Re: glob patterns Luuk <luuk@invalid.lan> - 2013-10-20 14:50 +0200

csiph-web