regexp support

Louis-David Mitterrand vindex@apartia.org
Wed, 10 Apr 2002 10:09:47 +0200


On Tue, Apr 09, 2002 at 10:02:32AM -0700, Ben Escoto wrote:
>   LDM> '\.exe$' will not exclude file.exe even though I did not give
>   LDM> any start anchor, one have to write '.*\.exe$' which seems a
>   LDM> bit counter-intuitive as regexps should match partially.
> 
> Hmm, I would have thought the opposite, that regular expressions
> should only match from the beginning.

That's what anchors are for. If you want to match from the beginning
then anchor the expression with '^'. At least that's the way it works in
Perl (sorry for mentionning that language ;-).

>   LDM> Also, is there a way of making exclude regexps
>   LDM> case-insensitive? It would be really useful for backing up
>   LDM> Windows partitions where one find such junk as file.DoC,
>   LDM> file.EXe, etc. Exclude patterns would be much simpler and more
>   LDM> readable with '\.(exe|sys)$' than
>   LDM> '.*\.([eE][xX][eE]|[sS][yY][sS])$'
> 
> If the regular expression starts with (?i) it will be interpreted
> case-insensitively.  So '(?i).*\.(exe|sys)$' may be what you want.

Great, I hadn't tried that. Apparently the Python regexp engine is
totally Perl-compatible (heh!).

> If you can think of a better way to specify this tell me, since we are
> in the process of adding shell-style patterns instead of regular
> expressions.  It seems inelegant to have a completely different switch
> (like --exclude-case-insensitive).  Maybe if the expression started
> with 'IGNORECASE:'?

I've just read the thread on --exclude --include syntax plans for
rdiff-backup. Please don't follow the rsync route by using their
perverted shell globing and rules. Much too complicated and inelegant
IMHO. Regular expressions are the way to go, please don't deviate from
your initial implementation (save the anchoring), everyone should know
and use regular expressions. The only rule should be that --include
overrides --exclude as in rsync.

Thanks for your consideration and a great tool,

-- 
    PHEDRE: J'ai conçu pour mon crime une juste terreur ;
            J'ai pris la vie en haine, et ma flamme en horreur.
                                          (Phèdre, J-B Racine, acte 1, scène 3)