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

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



On 2013-07-02 at 08:00 +0400, ZyX wrote:
> > > Phil Pennock's version worked great:
> > > 
> > > % 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]

Sorry, I was in a rush and missed that this was [A|B] which should of
course be written [AB] or (A|B) if the regexp language supports the
latter.  I should have caught that, instead of answering exactly what
was asked.

> > Unless AddDescription uses different regex engine then FilesMatch
> > answer is in the first link if searching for "htaccess case
> > insensitive regex": (?i:pattern).
> 
> It seems it does use different regex engine.

AddDescription does not take a regex.  It takes a filename pattern, or
what in shell is called a Glob.

It happens that some shells use [AB] as a glob pattern too, also to
introduce a character class, and that's why it works -- Apache supports
that syntax also.

Those places in Apache that do take regexps use the PCRE engine, the one
written by Philip Hazel for Exim, and which zsh also supports with
"zmodload zsh/pcre" (or setting the option to change =~ to use it,
"setopt rematch_pcre", which will auto-load that module when you first
use =~).

So those places in Apache which want regexps, you can test with zsh to
get a decent approximation, or use the pcretest(1) tool from the PCRE
distribution to get something designed to interactively test regexps
against inputs.

If you want to settle on that syntax, also consider installing the
pcregrep tool.  It's very nice to be able to relax and just use PCRE
syntax, even though the PCRE implementation is not as efficient as the
older tools (or the newer RE2 system).

-Phil



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