From: Andreas Schwab <schwab@linux-m68k.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Juri Linkov <juri@jurta.org>,
Lennart Borgman <lennart.borgman@gmail.com>,
Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: replace-regexp-in-string, using the dyn scoped variable STR
Date: Thu, 12 Nov 2009 16:58:11 +0100 [thread overview]
Message-ID: <m3639f4tws.fsf@hase.home> (raw)
In-Reply-To: <jwv1vk3ix5t.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 12 Nov 2009 10:26:35 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> (setq org-str (replace-regexp-in-string
>>> "&#x\\([a-f0-9]\\{2,4\\}\\);"
>>> (lambda (m)
>>> (char-to-string
>>> ;; Note: str is scoped dynamically from
>>> ;; `replace-regexp-in-string'.
>>> (+ (string-to-number (match-string 1 str) 16)
>
>> `str' has the same value as `m'.
>
> No, it doesn't: str is "the whole string" whereas m is only the
> (match-string 0) part of it
Which is always a prefix of str, and only different from str if the
match was empty.
> (which is why it's more convenient to use (match-string 1 str) in
> Lennart's example than to try and figure out where submatch 1 is in m,
The submatch 1 of m is at (match-beginning 1).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2009-11-12 15:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-11 19:18 replace-regexp-in-string, using the dyn scoped variable STR Lennart Borgman
2009-11-11 20:25 ` Stefan Monnier
2009-11-11 20:40 ` Lennart Borgman
2009-11-12 9:59 ` Juri Linkov
2009-11-12 10:17 ` Lennart Borgman
2009-11-12 15:26 ` Stefan Monnier
2009-11-12 15:58 ` Andreas Schwab [this message]
2009-11-12 17:05 ` Stefan Monnier
2009-11-12 22:07 ` Lennart Borgman
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=m3639f4tws.fsf@hase.home \
--to=schwab@linux-m68k.org \
--cc=emacs-devel@gnu.org \
--cc=juri@jurta.org \
--cc=lennart.borgman@gmail.com \
--cc=monnier@iro.umontreal.ca \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).