* case insensitive string match @ 2013-01-03 10:33 rahul 2013-01-03 12:08 ` Peter Stephenson [not found] ` <87zk0qzg1u.fsf@ft.bewatermyfriend.org> 0 siblings, 2 replies; 4+ messages in thread From: rahul @ 2013-01-03 10:33 UTC (permalink / raw) To: zsh-users [-- Attachment #1: Type: text/plain, Size: 421 bytes --] 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. I also dont suppose approximate matching can be used here (that's only for filename globbing, right?) -- rahul ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: case insensitive string match 2013-01-03 10:33 case insensitive string match rahul @ 2013-01-03 12:08 ` Peter Stephenson [not found] ` <87zk0qzg1u.fsf@ft.bewatermyfriend.org> 1 sibling, 0 replies; 4+ messages in thread From: Peter Stephenson @ 2013-01-03 12:08 UTC (permalink / raw) To: zsh-users On Thu, 03 Jan 2013 16:03:56 +0530 rahul <rahul2012@gmail.com> 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <87zk0qzg1u.fsf@ft.bewatermyfriend.org>]
[parent not found: <CACQNQ9P6c=hhD=X-Ur_mx+0LOknpezHsLwfz0UB9nK2hUQbpEw@mail.gmail.com>]
* Re: case insensitive string match [not found] ` <CACQNQ9P6c=hhD=X-Ur_mx+0LOknpezHsLwfz0UB9nK2hUQbpEw@mail.gmail.com> @ 2013-01-03 12:10 ` Frank Terbeck [not found] ` <CACQNQ9MUbO0n9kuKGiW5DSYrL12-jaCPvkJiRAPNa_=MNg=HNQ@mail.gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Frank Terbeck @ 2013-01-03 12:10 UTC (permalink / raw) To: rahul; +Cc: zsh-users (Forgot the mailinglist in my first reply, readding) rahul wrote: > On Thu, Jan 3, 2013 at 4:31 PM, Frank Terbeck <ft@bewatermyfriend.org>wrote: > >> rahul wrote: >> > 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. >> >> % things=( foo bar bfoor thing other frob ) >> % print -l ${(M)things:#*(#i)foo*} >> foo >> bfoor >> >> Thanks a lot. I think you meant: > > % print -l ${(M)things:#(#i)*foo*} Actually, I didn't. The position of the (#i) determines where the case-insensitivity starts. `*' matches everything anyway, so making it case-insensitive does not add much. > When i typed in what you wrote I got a "zsh bad pattern" Works here, maybe you're missing "setopt extended_glob"? Regards, Frank ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CACQNQ9MUbO0n9kuKGiW5DSYrL12-jaCPvkJiRAPNa_=MNg=HNQ@mail.gmail.com>]
* Re: case insensitive string match [not found] ` <CACQNQ9MUbO0n9kuKGiW5DSYrL12-jaCPvkJiRAPNa_=MNg=HNQ@mail.gmail.com> @ 2013-01-03 12:43 ` Frank Terbeck 0 siblings, 0 replies; 4+ messages in thread From: Frank Terbeck @ 2013-01-03 12:43 UTC (permalink / raw) To: rahul; +Cc: zsh-users rahul wrote: >> >> Thanks a lot. I think you meant: >> > >> > % print -l ${(M)things:#(#i)*foo*} >> >> Actually, I didn't. The position of the (#i) determines where the >> case-insensitivity starts. `*' matches everything anyway, so making it >> case-insensitive does not add much. >> >> > When i typed in what you wrote I got a "zsh bad pattern" >> >> Works here, maybe you're missing "setopt extended_glob"? >> >> >> I still get a bad pattern. I am on the latest zsh (homebrew on OSX). I > added an entry called FOO and it comes up in the match. > > setopt extended_glob > > print -l ${(M)things:#*(#i)foo*} > zsh: bad pattern: *(#i)foo* > > print -l ${(M)things:#(#i)*foo*} > foo > bfoor > FOO > > echo $ZSH_VERSION > 5.0.2 Weird, here both work. From zsh -f (which starts a shell without setup files): [snip] zsh% setopt extended_glob zsh% things=( foo bar bfoor thing FOO other frob ) zsh% print -l ${(M)things:#(#i)*foo*} foo bfoor FOO zsh% print -l ${(M)things:#*(#i)foo*} foo bfoor FOO [snap] Are you maybe setting the `kshglob' option? Does it work if you do: % setopt no_ksh_glob Regards, Frank -- In protocol design, perfection has been reached not when there is nothing left to add, but when there is nothing left to take away. -- RFC 1925 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-03 13:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-01-03 10:33 case insensitive string match rahul 2013-01-03 12:08 ` Peter Stephenson [not found] ` <87zk0qzg1u.fsf@ft.bewatermyfriend.org> [not found] ` <CACQNQ9P6c=hhD=X-Ur_mx+0LOknpezHsLwfz0UB9nK2hUQbpEw@mail.gmail.com> 2013-01-03 12:10 ` Frank Terbeck [not found] ` <CACQNQ9MUbO0n9kuKGiW5DSYrL12-jaCPvkJiRAPNa_=MNg=HNQ@mail.gmail.com> 2013-01-03 12:43 ` Frank Terbeck
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).