From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24081 invoked by alias); 1 Jul 2013 18:53:01 -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: 17841 Received: (qmail 12542 invoked from network); 1 Jul 2013 18:52:45 -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=1372704284; bh=Ip8hYIF4sbuWEnI7tIu+mcy34LzzPuHZM+G8pVyTQN4=; h=From:To:Cc:In-Reply-To:Subject:Date; b=WsEbgZKo4cNaLh/EX9QZR7HYUbulH6UnkAeM9q41S4NVI0Hkxax22c7o+pHm+vLMH DgjodngiY9LAyfKzVewcxeth8gH+eIHSENA/RWQZid7bCy0czE6h7PXZrJ/HI4Cm4H t/EAuW5CIKgDup7wiyYc98iGXHAp74ng4ciqrC4M= From: ZyX To: TJ Luoma Cc: Zsh-Users List In-Reply-To: Subject: Re: input foo, output '[F|f][O|o][O|o]'? MIME-Version: 1.0 Message-Id: <694051372704284@web26e.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 X-Yandex-Client: =?utf-8?B?WWFPbmxpbmUtYW5kcm9pZC0xLjc5LjM1OA==?= Date: Mon, 01 Jul 2013 22:44:44 +0400 Content-Transfer-Encoding: 7bit Content-Type: text/plain 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). 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". 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. 01.07.13, 22:12, "TJ Luoma" ": > > > Before I reinvent the wheel, I thought I'd ask if someone already had > (or knew of) a way to take a string of characters and output a 'case > insensitive' regex version. > > For example, if I input 'CrashPlan' I'd want to get out > [C|c][R|r][A|a][S|s][H|h][P|p][L|l][A|a][N|n] > > (Input will usually be ASCII letters, with an occasional number and > perhaps the occasional '-' or '_' but doesn't need to handle anything > more complex than that.) > > I tried Google but found it pretty impossible to make a good query for > something like this. > > TjL