[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: |
Michael Heerdegen |
Subject: |
Re: How to get a concatenation of the negations with rx (ex: [^a][^b])? |
Date: |
Sun, 12 Nov 2023 08:03:18 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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.
- How to get a concatenation of the negations with rx (ex: [^a][^b])?, Edgar Lux, 2023/11/11
- Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?,
Michael Heerdegen <=
- Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?, tomas, 2023/11/12
- Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?, Yuri Khan, 2023/11/12
- Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?, tomas, 2023/11/12
- Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?, Michael Heerdegen, 2023/11/12
- RE: How to get a concatenation of the negations with rx (ex: [^a][^b])?, Anders Munch, 2023/11/13
- Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?, tomas, 2023/11/13
Re: How to get a concatenation of the negations with rx (ex: [^a][^b])?, Emanuel Berg, 2023/11/13