On Sun, Nov 12, 2023 at 03:28:21PM +0700, Yuri Khan wrote: > On Sun, 12 Nov 2023 at 14:27, wrote: > > > Actually... the complement of a regular language is also a regular > > language, so there should be a regexp for that, too. > > In all(?) the courses that taught me the theory of regular languages, > the construction of a negation of a regexp would be suitable as the > practical part of an exam question sheet. > > As the first step, it is relatively straightforward to build a > non-deterministic finite state machine from the original regexp; then > we complement that NDFA’s set of accepting states; and then it’s a > tedious, error-prone job of building a regexp equivalent to that > complemented NDFA. OK -- this was roughly my train of thought: build the NFA, then invert that... OMG. Then I decided this is better left as an exercise to the reader. But since a regexp library is building the NFA anyway, I think it's surprising that it doesn't support negation. But I haven't ever tried to implement that; perhaps I'd know the answer then :) > The regexp thus obtained is often not a pretty sight, either. I believe you right away on that! Cheers -- t