From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: How to get a concatenation of the negations with rx (ex: [^a][^b])? Date: Mon, 13 Nov 2023 10:24:00 +0100 Message-ID: References: <1417367556.377258.1699733869853@fidget.co-bxl> <87leb3o3m1.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WjBwh8/cIQcCwHr3" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22360"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 13 10:25:10 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r2TBt-0005Xx-HG for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 13 Nov 2023 10:25:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2TBD-0004oc-0h; Mon, 13 Nov 2023 04:24:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r2TBA-0004oQ-Ol for help-gnu-emacs@gnu.org; Mon, 13 Nov 2023 04:24:24 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r2TAz-0007qf-9Q for help-gnu-emacs@gnu.org; Mon, 13 Nov 2023 04:24:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=AUh2FoHBWRN8Iym3izTAZ4+p1yBGWIMH37hI3p1LwvQ=; b=dpLfS2ZM6UpQYfdLzawnN6R+A+ +uDhEw5UurfyzuMM8bZBpRj4Cgu8A5tMzSuxATSoj1mM+kpuH74qakwiki6Ne+2ZxHT8L+s09usfU vARhAGGh5D/qXN3+VdsJvql+ZSdX37/9Im9UdR9XOgkW27Uwt6tpNJiaTVMwj69FTj7VAuq/v/c8i zkzYJPmSUTFuxidzgIYBvYpEciKFpCzDlKJV/0kQKAkh9HuckIPcnAIJD/c+oOyKVOac7SQK7Buq0 W7wUqocuykISIYa09LC93MtKHmTYrBBvIfpIL85tCfaoFs5tMCkfSscrL2aRv5jA+TJsTH/N5D8nv X1pvStRQ==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1r2TAm-0005Wb-J0 for help-gnu-emacs@gnu.org; Mon, 13 Nov 2023 10:24:00 +0100 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145504 Archived-At: --WjBwh8/cIQcCwHr3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 reade= r. >=20 > 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 ca= n remember it. >=20 > First convert to DFA. Which already involves a power set. Uh, oh ;-) > For every node, add an outgoing edge to the accepta= nce state for every character that doesn't already have an outgoing node. R= emove all edges to the acceptance state that were in the original DFA. >=20 > 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 reg= ular expression "not ab", and if you were looking for a two-character strin= g that is not "ab", then a general negation operator isn't going to help yo= u, 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 --=20 t --WjBwh8/cIQcCwHr3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZVHrKgAKCRAFyCz1etHa RnExAJsH3AmayecRCxYTDnPFMoHKdaMzAwCbBRD6tMFHR54DN6GZahj/uB+V3Vo= =JLzl -----END PGP SIGNATURE----- --WjBwh8/cIQcCwHr3--