[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dash in regexp character classes: Beginnig vs. end [was: Use the cha
From: |
Robert Pluim |
Subject: |
Re: Dash in regexp character classes: Beginnig vs. end [was: Use the characters "+" and "-" in regular expressions] |
Date: |
Thu, 20 May 2021 10:08:37 +0200 |
>>>>> On Thu, 20 May 2021 09:15:29 +0200, "tomas@tuxteam.de" <tomas@tuxteam.de>
>>>>> said:
>> I quoted this from (elisp) `Regexp Special':
>>
>> To include a ‘-’, write ‘-’ as the first or last
>> ^^^^^^^^^^^^^
>> character of the character alternative, or as the
>> upper bound of a range. Thus, ‘[]-]’ matches both
>> ‘]’ and ‘-’.
>>
>> That's from Emacs 26 (and all prior releases, at least
>> as far back as Emacs 20). But yes, they changed that
>> text for Emacs 27, to this:
>>
>> To include ‘-’, put it at the end.
>> ^^^^^^^^^^
>> ___
>>
>> For Emacs 20, it says this:
>>
>> To include a `-', write `-' as the first or last
>> character of the character alternative, or put it
>> after a range. Thus, `[]-]' matches both `]' and
>> `-'.
tomas@tuxteam> Oh. That is interesting. Anyone knows why that change?
It makes the description and usage simpler and more regular, and less
error-prone.
Since I never remember the rules for this stuff anyway, I do this
instead:
(rx (or ?- ?+ ?.))
=> "[+.-]"
but of course parenthesis-like characters still need to be escaped:
(rx (or ?\) ?\] ?-))
=> "[])-]"
Robert
--
- Re: [External] : Use the characters "+" and "-" in regular expressions, (continued)
- Re: [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Yuri Khan, 2021/05/20
- [External] : Use the characters "+" and "-" in regular expressions, steve-humphreys, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Eduardo Ochs, 2021/05/20
- RE: [External] : Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/21
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/20
- Dash in regexp character classes: Beginnig vs. end [was: Use the characters "+" and "-" in regular expressions], address@hidden, 2021/05/20
- Re: Dash in regexp character classes: Beginnig vs. end [was: Use the characters "+" and "-" in regular expressions],
Robert Pluim <=
- RE: [External] : Re: Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/19
- RE: [External] : Re: Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/19
Re: Use the characters "+" and "-" in regular expressions, tomas, 2021/05/19
RE: [External] : Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/19