Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: input foo, output '[F|f][O|o][O|o]'?



+1 Alex's recommendation. The optimal answer depends on the capabilities of
the regex engine you're targeting. In zsh, for example, you can use the #i
modifier to make globs case insensitive. There's also the zsh/pcre module
which provides Perl compatible regex support including case insensitive
matches. In short, for any reasonable regex implementation there is no need
to resort to something as clumsy  as what you propose. Keep in mind to that
for anything other than ASCII this is impossible, for all practical
purposes, to implement correctly using the strategy you had in mind.


On Mon, Jul 1, 2013 at 4:51 PM, Alex Satrapa <grail@xxxxxxxxxxxxxx> wrote:

> Since the topic is Regular Expressions, I will take the opportunity to
> recommend the O'Reilly book, "Mastering Regular Expressions" by Jeffrey
> Freidl. Even if you only work through the first few chapters (it provides
> examples for you to play with and learn), it will be worth the investment.
>
> I am a very happy "student" (disciple, even) of Jeffrey Freidl's writing,
> and I have many O'Reilly books in my library.
>
> Alex Satrapa
>
> On 02/07/2013, at 3:59, "TJ Luoma" <luomat@xxxxxxxxx> 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]
> >
> > (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
>



-- 
Kurtis Rader
Caretake of the exceptional canines Junior and Chino


Messages sorted by: Reverse Date, Date, Thread, Author