[pcre-dev] [Bug 1380] New: Report match when doesn't match a…

Page principale
Supprimer ce message
Auteur: Sorin
Date:  
À: pcre-dev
Sujet: [pcre-dev] [Bug 1380] New: Report match when doesn't match and vice-versa
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1380
           Summary: Report match when doesn't match and vice-versa
           Product: PCRE
           Version: N/A
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: wishlist
          Priority: medium
         Component: Code
        AssignedTo: ph10@???
        ReportedBy: sxn02@???
                CC: pcre-dev@???



Hi,

I have numerous instances in which I'd like to have a match when a
subexpression does not match (to define exceptions mainly). For instance, match
word1, but only if it is not preceded by word2 at a distance of up to 6 words.
There is the negative lookbehind, of course, but this is not allowing
expressions of unknown length.

I think it would be easy to implement such a feature: the matching itself is
the same, only the reported result is reversed. Syntactically, it can be
introduced by a new modifier (?n) and suspended by the corresponding (?-n), "n"
standing for "negated". With that in place, my example becomes (?n)word2
(?:words ){0,6}(?-n)word1.

This solution has the advantage of being backward compatible (no need to change
any of the existing regexes to adopt this new functionality).

If capturing is enabled (by our usual syntax), it shows what part of the
subject text caused the match rejection.

Thanks,
Sorin Schwimmer


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email