Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: case insensitive string match



On Thu, 03 Jan 2013 16:03:56 +0530
rahul <rahul2012@xxxxxxxxx> wrote:
> I've been using this for doing some filtering from an array:
> 
>                 matched=(${(M)array:#*$patt*})
> 
> Now I need to have an option of case insensitive search. Looked
> through the user's guide and other sources but I don't see a flag to
> ignore case. Is there a way without changing this to use grep.
 

Make sure the extendedglob option is on:

                 setopt extendedglob

and use

                 matched=(${(M)array:#(#i)*$patt*})

> I also dont suppose approximate matching can be used here (that's
> only for filename globbing, right?)

That should work fine; apart from glob qualifiers, which can't be used
with patterns whatever effect they have, about the only things limited
to filename globbing are things that really only apply to files.

pws



Messages sorted by: Reverse Date, Date, Thread, Author