Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: array filtering
On Sun, Jun 9, 2024, at 1:49 PM, Ray Andrews wrote:
> arr=( ${(M)arr:#(#i)*/*$1[^/]*/} )
>
> ... ends up too narrow, it catches a completed name but misses the
> exact match which puzzles me because I'd read that: '... anything
> except a slash, any number of characters or none' -- which should find
> the exact match: ' [^/]* ' should simply be empty, no?
No. These are shell patterns, not regular expressions. "[^/]*"
matches one non-"/" character followed by zero or more arbitrary
characters.
Since you're using EXTENDED_GLOB (something you always neglect to
mention), you can use "[^/]#" to match zero or more non-slashes.
arr=(${(M)arr:#(#i)*/[^/]#$1[!/]#/})
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author