From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.help 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 Message-ID: <87lf896d4q.fsf@gmail.com> References: <20210519213207.GD4855@tuxteam.de> <20210520071529.GA1127@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23767"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "help-gnu-emacs@gnu.org" To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 20 10:11:48 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ljdmW-00064d-C7 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 20 May 2021 10:11:48 +0200 Original-Received: from localhost ([::1]:54370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljdmV-00087Q-Cg for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 20 May 2021 04:11:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljdjX-0004qK-Ei for help-gnu-emacs@gnu.org; Thu, 20 May 2021 04:08:43 -0400 Original-Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:46721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljdjV-0007rL-Kx for help-gnu-emacs@gnu.org; Thu, 20 May 2021 04:08:43 -0400 Original-Received: by mail-wr1-x42b.google.com with SMTP id y14so14543367wrm.13 for ; Thu, 20 May 2021 01:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=DXlGCWD0Y2MzSZ26iMH5Dqy4w6itOozS1jSAy9+wAH4=; b=Cxa01iEjTwkJ58NNk5k2QeRH/iSCDm1kDKQ9g2QXkwo2Fk+gOM02abHs7sJyh4SjdJ eWxl3PYOLVyi1vQ4sDwEbEKROz6OQsg143vEQgC6zUiXuyDJzu3AInsJyVcW0CW2EgTM 4B7fXgu0yUpwtTIAaiBK0kMoYvBZiCD0wArSsZbPjG9bQkXqiQYjKYsNmTXphhSQRcDr WquMMSgz0FByTj1p2NErBqksQfAkEbixfpA6r89zFiwD3ZIsuSxxNNBQDKXJe3PNzRRc R9WYhZNVmMnrWJKVkX0IbBFWp9bmahHKKZkrHjkdxQuzVYsLAAPg5lZKk4Lc/N2veXdo 6v8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:mime-version :content-transfer-encoding; bh=DXlGCWD0Y2MzSZ26iMH5Dqy4w6itOozS1jSAy9+wAH4=; b=Q23BXiupg4sVL0/Vwy+f/9aXdbOTx67R3AK6r4BTCG62I7JnaZx3JTTGyvF9wqxyTa l78DH/lialqL03tsZ20ySpc0JlMNRtIT/21N6L5DaS8GjHv20i1xJXom4cOmiCYLP/Y2 FJhhKhHtID59w6WP/DP6Rob6Fe0ZbDMghnC6NJd6p0Qc78i+okGREXea6I7mxnDlO43Q 4R7DLqZ5CQEfdeEGSe7nK2SNJstGljlzPbNoK2lccmyKX4zRDbWGq+rEvXTe430xnvxz yFzeg31ZLa5eRnuRz8bZQZvU9ZpZ7DMSx8VUo/Ri6Gu4iufYzjdPfzL9SzMsuxQ+NGAm IxEA== X-Gm-Message-State: AOAM533DrUGMi4WkNBnA/F4mN+TGm8SCQ8bGShmVu+KezZBOSYH2q6pg pe5hDah0c9Ecw1jZFhVTPSinaBqm5rQ= X-Google-Smtp-Source: ABdhPJzng/3bKa1EFXvik4SW+Rc71SheGgKpSYs7RassCKoQqEhso0rB+vj4ookgNRT0bcQhbm7ZWw== X-Received: by 2002:a5d:6d83:: with SMTP id l3mr2920058wrs.241.1621498119366; Thu, 20 May 2021 01:08:39 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id d3sm2240239wrs.41.2021.05.20.01.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 01:08:38 -0700 (PDT) Gmane-Reply-To-List: yes In-Reply-To: <20210520071529.GA1127@tuxteam.de> (tomas@tuxteam.de's message of "Thu, 20 May 2021 09:15:29 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=rpluim@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129949 Archived-At: >>>>> On Thu, 20 May 2021 09:15:29 +0200, "tomas@tuxteam.de" said: >> I quoted this from (elisp) `Regexp Special': >>=20 >> To include a =E2=80=98-=E2=80=99, write =E2=80=98-=E2=80=99 as the f= irst or last >> ^^^^^^^^^^^^^ >> character of the character alternative, or as the >> upper bound of a range. Thus, =E2=80=98[]-]=E2=80=99 matches both >> =E2=80=98]=E2=80=99 and =E2=80=98-=E2=80=99. >>=20 >> 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: >>=20 >> To include =E2=80=98-=E2=80=99, put it at the end. >> ^^^^^^^^^^ >> ___ >>=20 >> For Emacs 20, it says this: >>=20 >> 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 ?- ?+ ?.)) =3D> "[+.-]" but of course parenthesis-like characters still need to be escaped: (rx (or ?\) ?\] ?-)) =3D> "[])-]" Robert --=20