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 20:26:06 +0100 [thread overview]
Message-ID: <ZVJ4Tni49Hr9+m08@tuxteam.de> (raw)
In-Reply-To: <87o7g0f1k3.fsf@dataswamp.org>
[-- Attachment #1: Type: text/plain, Size: 829 bytes --]
On Sat, Nov 11, 2023 at 10:00:12PM +0100, Emanuel Berg wrote:
> Edgar Lux wrote:
>
> > 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")))
> >
> > but that got me
> >
> > Debugger entered--Lisp error: (error "Illegal argument
> > to rx ‘not’: (seq \"a\" \"b\")")
> >
> > The error is very clear, 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")))
> >
> > which produces
> >
> > "[^a][^b]"
>
> (rx (not (any "a" "b")))
>
> "[^ab]"
(string-match "[^a][^b]" "ba")
=> 0 ; note: 0 means it found a match at pos 0
(string-match "[^ab]" "ba")
=> nil
No.
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2023-11-13 19:26 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 [this message]
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
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=ZVJ4Tni49Hr9+m08@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.