From: ZyX <kp-pav@yandex.ru>
To: TJ Luoma <luomat@gmail.com>
Cc: Zsh-Users List <zsh-users@zsh.org>
Subject: Re: input foo, output '[F|f][O|o][O|o]'?
Date: Mon, 01 Jul 2013 22:44:44 +0400 [thread overview]
Message-ID: <694051372704284@web26e.yandex.ru> (raw)
In-Reply-To: <E2BB9B64-ECE8-4B69-BEEB-05B010699AB4@gmail.com>
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@gmail.com>":
>
>
> 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
next prev parent reply other threads:[~2013-07-01 18:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 17:59 TJ Luoma
2013-07-01 18:44 ` ZyX [this message]
2013-07-02 0:58 ` TJ Luoma
2013-07-02 1:30 ` Lawrence Velázquez
2013-07-02 1:53 ` Benjamin R. Haskell
2013-07-02 4:24 ` TJ Luoma
2013-07-02 3:51 ` ZyX
2013-07-02 4:00 ` ZyX
2013-07-02 23:24 ` Phil Pennock
2013-07-01 19:37 ` Phil Pennock
2013-07-02 0:24 ` TJ Luoma
2013-07-01 23:51 ` Alex Satrapa
2013-07-02 0:38 ` Kurtis Rader
2013-07-02 1:11 ` TJ Luoma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=694051372704284@web26e.yandex.ru \
--to=kp-pav@yandex.ru \
--cc=luomat@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).