[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replace-regexp-in-string, using the dyn scoped variable STR
From: |
Andreas Schwab |
Subject: |
Re: replace-regexp-in-string, using the dyn scoped variable STR |
Date: |
Thu, 12 Nov 2009 16:58:11 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Stefan Monnier <address@hidden> 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, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."