From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?
Date: Sun, 12 Nov 2023 08:03:18 +0100 [thread overview]
Message-ID: <87leb3o3m1.fsf@web.de> (raw)
In-Reply-To: 1417367556.377258.1699733869853@fidget.co-bxl
Edgar Lux <edgarlux@mailfence.com> writes:
> Hello. I am trying to get this regular expression:
>
> "[^a][^b]"
>
> in an easier way. I thought that I could do
>
> (rx (not (seq "a" "b")))
No,
> but that got me
>
> Debugger entered--Lisp error: (error "Illegal argument to rx
> ‘not’: (seq \"a\" \"b\")")
this would also express something different: `not' is not distributive
over `seq' concatenation of regexps -- a string starting with a character
different from 'a' followed by a character different from 'b' is something
different than a string not starting with "ab".
> The error is very clear,
I think `match a string not starting with "ab"' is not even expressible
using a standalone standard regexp. That would require regexps to be
able to backtrack when matching, and it would be something more general
than regexps.
> but I would like to know if there is a smart way of achieving the same
> without having to type:
>
> (rx (seq (not "a") (not "b")))
Unless you actually wanted to express something different: the `seq'
wrapper is redundant, but with
(rx (not "a") (not "b"))
a local maximum of smartness is reached.
Michael.
next prev parent reply other threads:[~2023-11-12 7:03 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 [this message]
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
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=87leb3o3m1.fsf@web.de \
--to=michael_heerdegen@web.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.