>I can tighten the definition up.  If there have been calls for a 
>(?^baz) type construct before, there will be again.  It is a matter of
>getting the definition straightforward and useable.


Are you really just wanting !/BAD/ there?  That is, something
that isn't matched by /BAD/?  One would, of course, normally
simply write !/BAD/, or perhaps !~ /BAD/.  However, if reading
a config file of patterns, you can't go invert the sense of the
match.

Well, easily, that is.

The Perl Cookbook, in Chapter 6, has these solutions:

 *  True if either C</ALPHA/> or C</BETA/> matches, like C</ALPHA/ || /BETA/>:

        /ALPHA|BETA/

 *  True if both C</ALPHA/> and C</BETA/> match, but may overlap, meaning
    that C<"BETALPHA"> should be ok, like C</ALPHA/ && /BETA/>:

        /^(?=.*ALPHA)(?=.*BETA)/s

 *  True if both C</ALPHA/> and C</BETA/> match, but may not overlap,
    meaning that C<"BETALPHA"> should fail:

        /ALPHA.*BETA|BETA.*ALPHA/s

 *  True if pattern C</PAT/> does not match, like C<$var !~ /PAT/>:

        /^(?:(?!PAT).)*$/s

 *  True if pattern C<BAD> does not match, but pattern C<GOOD> does:

        /(?=^(?:(?!BAD).)*$)GOOD/s

I suspect the penultimate is just what you're looking for.  

Or shall I go back and deepread the whole thread? :-(

--tom

Reply via email to