[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnu-arch-users] Preventing matches in regular expressions
From: |
Jan Hudec |
Subject: |
Re: [Gnu-arch-users] Preventing matches in regular expressions |
Date: |
Wed, 11 Aug 2004 08:42:48 +0200 |
User-agent: |
Mutt/1.5.6+20040722i |
On Tue, Aug 10, 2004 at 20:42:25 +0100, Andrew Suffield wrote:
> On Mon, Aug 09, 2004 at 03:29:53PM -0400, Aaron Bentley wrote:
> > That would add or update the regexes in the .arch-inventory. But since
> > backup is tried before unrecognized, the rule for backup must match
> > every zip file except 'fox.zip'
> >
> > Here's what I've finally come up with, using the example 'fox.zip':
> >
> > backup ^(.{0,2}|.{4}.*|[^f]..|.[^o].|..[^x])\.zip$
>
> Yes, that's right. It's an old and rather evil trick.
>
> > But man, oh man, that's an ugly regex, and it'll only get less readable
> > with longer filenames and multiple filenames.
> >
> > Does anyone know a better general solution?
>
> Well, you can implement regexp extensions that construct these
> things. They can get a bit memory-hungry though.
>
> More normally you just step outside the bounds of regexps though. Perl
Lookahead/lookback assertions are perfectly regular. They definitely can
be expressed as a NFA. And negative lookahead assertion is all you need.
Using the vim syntax:
^\(foo\.zip$\)address@hidden
(well, it's actualy not exactly what I'd want. I'd want a negation per
se -- say ! is negation and & is conjunction (vim has conjunction, btw).
Then it whould simply be:
^((foo)!&.*)\.zip$
And it would still be regular expression. That is, it would still
describe a regular grammar (L3).
Obviously though, the regular expression must be in hackerlab rx syntax.
> does it by having regexps that aren't; perlre cannot be expressed as
> an NFA, although it still uses one to do *most* of the work.
Perl expression are not regular, but for completely different reasons.
Mainly because they can be recursive, because they can do backreferences
and because they can include arbitrary code.
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec
<address@hidden>
signature.asc
Description: Digital signature
Re: [Gnu-arch-users] Preventing matches in regular expressions, Andrew Suffield, 2004/08/10
Re: [Gnu-arch-users] Preventing matches in regular expressions,
Jan Hudec <=
Re: [Gnu-arch-users] Preventing matches in regular expressions, Tom Lord, 2004/08/11
Re: [Gnu-arch-users] Preventing matches in regular expressions, Tom Lord, 2004/08/11