unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Match empty string at begin/end of symbol
Date: Wed, 04 Jul 2018 22:22:15 +0300	[thread overview]
Message-ID: <83zhz6n6vs.fsf@gnu.org> (raw)
In-Reply-To: <20180704114346.73df0142@gauss> (message from Joe Riel on Wed, 4 Jul 2018 11:43:46 -0700)

> Date: Wed, 4 Jul 2018 11:43:46 -0700
> From: Joe Riel <joer@san.rr.com>
> 
> The regular expressions '\_<' and '\_>'
> seem to be broken in Emacs 25.1.1.  Consider
> 
> (let ((str "3+ab"))
>   (and (string-match "\\<[a-zA-Z][a-zA-Z0-9]*" str)
>        (match-string 0 str)))
>  
> That returns "ab", as expected.  Change the "\\<" to "\\_<"
> and it no longer matches.  Why not?
> 
> (let ((str "3+ab"))
>   (and (string-match "\\_<[a-zA-Z][a-zA-Z0-9]*" str)
>        (match-string 0 str)))

The result of the last form depends on the major mode of the buffer
where (or in whose minibuffer) you evaluate it.  If it's Lisp or its
derivatives, it indeed should not match because a Lisp symbol can
legitimately be named "3+ab", and so "ab" is not at a symbol
boundary.  But if you try the same in a buffer whose major mode is C
Mode, you surely get a match, because '+' is not a symbol-constituent
character in C.

IOW, I don't think there's a bug here.  It's behaving as intended.



  parent reply	other threads:[~2018-07-04 19:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 18:43 Match empty string at begin/end of symbol Joe Riel
2018-07-04 19:21 ` Noam Postavsky
2018-07-04 19:22 ` Eli Zaretskii [this message]
2018-07-04 19:37   ` Joe Riel
2018-07-04 19:25 ` Teemu Likonen

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83zhz6n6vs.fsf@gnu.org \
    --to=eliz@gnu.org \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).