Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: input foo, output '[F|f][O|o][O|o]'?
- X-seq: zsh-users 17842
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>
- Subject: Re: input foo, output '[F|f][O|o][O|o]'?
- Date: Mon, 1 Jul 2013 15:37:17 -0400
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201210; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=CAxcKnCN1srL7spVdG/G1AbsdIdr3+mRgfYp/B09XWg=; b=p4w3V0aBuypKVi2DO4p4fwW3lfZQ1vmSSZL88ysKtn1SMjo/itZ2skpPCI9ZablVpM8ltzpL8rDUMhhxEv0Ed2mcZeFB3jiWBBXmGSii62UWh1dnEU2ev5hkLBolpOXLBWd+c5ejPhwAtICKDq0ZLKBpch3FrkBwM125b3h3tOM=;
- In-reply-to: <E2BB9B64-ECE8-4B69-BEEB-05B010699AB4@gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: TJ Luoma <luomat@xxxxxxxxx>, Zsh-Users List <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <E2BB9B64-ECE8-4B69-BEEB-05B010699AB4@gmail.com>
On 2013-07-01 at 13:59 -0400, TJ Luoma wrote:
> 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]
% 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]
%
If this is for use within zsh, then as ZyX suggests it's simpler, even
for regexp cases:
setopt rematch_pcre
[[ "cRAShpLAn" =~ (?i)$foo ]]
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author