emacs-devel
[Top][All Lists]
Advanced

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

Re: replace matches in any string


From: Davis Herring
Subject: Re: replace matches in any string
Date: Thu, 2 Sep 2010 15:40:52 -0700 (PDT)
User-agent: SquirrelMail/1.4.8-5.el5_4.10.lanl3

> This doesn't help at all.
>
> The use case is that you had some string do a match, but you don't have
> access to the string variable.  You just want the matches that you know
> were made, aka perlish $1, $2, $3.  I reiterate my first posting on this
> issue as a feature request.

I don't know why you'd permanently lose the string you matched against,
but m-s-r does let you write

(defun format-matches (fmt regexp str)
  "Replace \\1 \\& etc. in FMT with matches from REGEXP against STR."
  (string-match regexp str)
  (match-substitute-replacement fmt nil nil str))

...in which case you only need to pass the string to one function.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.



reply via email to

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