Zsh Mailing List Archive
Messages sorted by:
Re: input foo, output '[F|f][O|o][O|o]'?
- X-seq: zsh-users 17841
- From: ZyX <kp-pav@xxxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>
- Subject: Re: input foo, output '[F|f][O|o][O|o]'?
- Date: Mon, 01 Jul 2013 22:44:44 +0400
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- 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=
- In-reply-to: <E2BB9B64-ECE8-4B69-BEEB-05B010699AB4@gmail.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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" <luomat@xxxxxxxxx>":
> 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
> (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.
Messages sorted by: