Interesting that you have mentioned it, as I stumbled upon similar
problem, alas a bit simpler one.
In particular, I would like to be able to negate a match of a regular
expression. In other words, construct a regular r' expression which
matches everything that does not match regular expression r.
In PCRE the common way of expressing that is:
(?!r).*
but that, not being a regular expression, is not supported by re2.
I would like to propose a partial solution to this such that if the
regex is of the form:
(?!r).*
it is simplified to simply:
r
and an internal flag “negate” is set. This step may be done
iteratively.
Do people think that would be feasible and useful?
A more advance set up could look for regexp of the form
(?!r)s
and transform it into a pair r, s such that a string must match s and
must not much r, but that's probably for the future.