From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8371 invoked by alias); 2 Jul 2013 04:00:57 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17850 Received: (qmail 20592 invoked from network); 2 Jul 2013 04:00:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf-ipv4.yandex.ru designates 77.88.61.49 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1372737643; bh=ZVbtDgys0KPGhmXy64u1Pqi//UoCSFj5QFaE+JQffQg=; h=From:To:Cc:In-Reply-To:Subject:Date; b=AYu0jixGGrSW3NZHYaHZhfnlSy5jLEjjqtgY14qITorhoo1U/v+7fqvkS4fzxxXdp ws1P/ePvWKtyEEhjfY1ySlPkIHdYjgZsbdbDQNU/WJSk0RlfFF9s/2DmKY2xULOWoK lMeBNuAtp3tcc85UO9in/2DbdfsC0RkFdd3K3My0= From: ZyX To: TJ Luoma Cc: Zsh-Users List In-Reply-To: <215891372737080@web15e.yandex.ru> Subject: Re: input foo, output '[F|f][O|o][O|o]'? MIME-Version: 1.0 Message-Id: <497991372737643@web23e.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 X-Yandex-Client: =?utf-8?B?WWFPbmxpbmUtYW5kcm9pZC0xLjc5LjM1OA==?= Date: Tue, 02 Jul 2013 08:00:43 +0400 Content-Transfer-Encoding: 7bit Content-Type: text/plain 02.07.13, 07:51, "ZyX" ": > > > > 02.07.13, 04:58, "TJ Luoma" ": > > > > > > On 1 Jul 2013, at 14:44, ZyX wrote: > > > > > I do not think you will find a way to do this. All regex engines > > > (precisely, programs that are using them) I know support a way to set > > > case sensitivity for the whole regular expression and some support > > > toggling this for a part of regular expression. In grep this is an -i > > > switch, for vim it is either /i or \c/\C, for sed this is /i, for PCRE > > > and perl this is additionally (?i) "atom" (additionally to other ways > > > of toggling the behavior which are highly dependent on programs > > > embedding PCRE; for perl this is usual /i flag). Even zsh globs do > > > support (#i). > > > > Phil Pennock's version worked great: > > > > % foo=CrashPlan > > % for c in ${(s::)foo}; do print -n "[${(U)c}|${(L)c}]";done; print > > [C|c][R|r][A|a][S|s][H|h][P|p][L|l][A|a][N|n] > > % > > This is a bicycle. You asked for a standard way, you will not find it. > > > > > > > > By the way, what regex engine is your output for? Any I am aware of > > > parse "[N|n]" as "either one of three characters: N, n, or pipe". > > > > Really? I can think of several that support it. Maybe it's because I'm > > old enough to remember when a lot of these utilities didn't have 'ignore > > case' > > > > % echo "foo\nbar\nbat" | egrep -v '[F|f]' > > bar > > bat > > > > % echo "foo\nbar\nbat" | sed 's#[F|f][O|o][O|o]#XXX#g' > > XXX > > bar > > bat > > > > You can also use it for matching case/esac : > > > > case "$i" in > > [C|c][R|r][A|a][S|s][H|h][P|p][L|l][A|a][N|n]) > > echo "matched crashplan" > > ;; > > > > *) > > echo "No Match" > > ;; > > > > esac > > It is not a disproof. Check it with pipe symbol in input. > > > > > > > > I am also assuming XY problem here: what for do you need such > > > conversion? You should consider lowercasing the tested string if > > > nothing like -i is available. > > > > It's for use with the AddDescription directive for .htaccess which (from > > what I understand) takes its case sensitivity from the underlying > > filesystem when matching filenames. There's no "ignore case" flag or > > anything else that I can use with it, so my only option (at least, the > > only one I can think of) is the one that I suggested. For example, if I > > wanted to add this for any files which start with 'BBEdit' (case > > insensitive) this is what I'd need to use: > > > > AddDescription "A text editor > > that doesn't suck" [B|b][B|b][E|e][D|d][I|i][T|t]* > > > > I verified that it works, but typing that stuff manually is tedious and > > highly error prone, which made it the perfect place for a shell script > > :-) > > Unless AddDescription uses different regex engine then FilesMatch answer is in the first link if searching for "htaccess case insensitive regex": (?i:pattern). It seems it does use different regex engine.