all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?
Date: Mon, 13 Nov 2023 10:24:00 +0100	[thread overview]
Message-ID: <ZVHrMBGXYoGZLatb@tuxteam.de> (raw)
In-Reply-To: <VI1PR05MB106809A8B9B549FA23CDA3BF5B4B3A@VI1PR05MB10680.eurprd05.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]

On Mon, Nov 13, 2023 at 08:46:15AM +0000, Anders Munch wrote:
> tomas@tuxteam.de wrote:
> > 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.
> 
> At the DFA level it's easy.  So you can just convert the NFA to a DFA and work from there.  I did that exercise once upon a time, let me see if I can remember it.
> 
> First convert to DFA.

Which already involves a power set. Uh, oh ;-)

>                       For every node, add an outgoing edge to the acceptance state for every character that doesn't already have an outgoing node. Remove all edges to the acceptance state that were in the original DFA.
> 
> The main problem is not implementation.  It's that it's not obvious what to use them for in the variable-length searches that regexes are typically used for.  It's just confusing that the string "abz" is a match for the regular expression "not ab", and if you were looking for a two-character string that is not "ab", then a general negation operator isn't going to help you, at least not by itself.

Yes, I guess this is more or less what I hand-waved away with
my "modulo corner cases" (ain't natural language wonderful? ;)

For your example, one would have to append .* to all non-end
anchored (i.e. those not ending with $) regexps to better match
usual expectations. But who knows whether that's all.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2023-11-13  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-11 20:17 How to get a concatenation of the negations with rx (ex: [^a][^b])? Edgar Lux
2023-11-11 21:00 ` Emanuel Berg
2023-11-13 19:26   ` tomas
2023-11-12  7:03 ` Michael Heerdegen
2023-11-12  7:26   ` tomas
2023-11-12  8:28     ` Yuri Khan
2023-11-12 10:38       ` tomas
2023-11-12 11:53         ` Michael Heerdegen
2023-11-13  8:46         ` Anders Munch
2023-11-13  9:24           ` tomas [this message]
2023-12-24 11:54             ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZVHrMBGXYoGZLatb@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.