help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?


From: tomas
Subject: Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?
Date: Sun, 12 Nov 2023 11:38:29 +0100

On Sun, Nov 12, 2023 at 03:28:21PM +0700, Yuri Khan wrote:
> On Sun, 12 Nov 2023 at 14:27, <tomas@tuxteam.de> 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

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]