[Top][All Lists]

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

Re: replace-match: end of the replacement text for strings

From: Kai Großjohann
Subject: Re: replace-match: end of the replacement text for strings
Date: Mon, 16 Sep 2002 21:51:06 +0200
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu)

Roland Winkler <address@hidden> writes:

> "Stefan Monnier <address@hidden>" 
> <> writes:
>> >>>>> "Roland" == Roland Winkler <address@hidden> writes:
>> > When I use replace-match to operate on a string, is there an easy
>> > way to find out the end of the replacement text in the string that
>> > is returned by replace-match (like point in a buffer)? I have in
>> > mind the situation when the optional arg LITERAL is nil, i.e., the
>> > replacement text is `derived' from the string that is passed to
>> > replace-match.
>> You should be able to get it by looking at the size of the string
>> before and after replacement as well as the size of the replaced
>> text. It's a bit round-about, but I can't think of any other way.
> In general, doesn't this work only when I know the replacement text
> -- which I don't know when I have LITERAL set to nil and I am using
> something like "\1" in the replacement?

You need to do some arithmetic to find out the value you want.

length of replaced text = new length of string
                        - old length of string 
                        + length of text to be replaced

~/.signature is: umop 3p!sdn    (Frank Nobis)

reply via email to

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