help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RE: [External] : Use the characters "+" and "-" in regular expressi


From: steve-humphreys
Subject: Re: RE: [External] : Use the characters "+" and "-" in regular expressions
Date: Thu, 20 May 2021 08:26:39 +0200

Have done as follows but cannot see the result.  Have read through
the table of valid format specifications, and the other options are
mostly about printing numbers.

(message " ")
(message "*** ***")
(setq s (string-match "[+]+"  "++++++++++++++++"))
message("%s" s)
(setq s (string-match "[+-]+" "++++++++++++++++"))
message("%s" s)
(setq s (string-match "[+-]+" "----------------"))
message("%s"  s)






> Sent: Thursday, May 20, 2021 at 9:59 AM
> From: "Drew Adams" <drew.adams@oracle.com>
> To: "tomas@tuxteam.de" <tomas@tuxteam.de>, "help-gnu-emacs@gnu.org" 
> <help-gnu-emacs@gnu.org>
> Subject: RE: [External] : Re: Use the characters "+" and "-" in regular 
> expressions
>
> > Hm. According to the docs, the dash should go last, but 
> > a test actually confirms that it works in first position.
> 
> 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
>    `-'.
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]