[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can't get replace-match to replace intended match-data
From: |
Jonas Jarnestrom |
Subject: |
Re: Can't get replace-match to replace intended match-data |
Date: |
Sun, 30 Sep 2001 11:26:05 +0200 (MET DST) |
> >
> > (defun cs-head-set-target ()
> > ""
> > (interactive)
> > (goto-char (point-min))
> > (and (re-search-forward "Target: +<\\(.*\\)>" 400 'noerr)
> ^
> change the . to [^>] here-----+
> ^
> no further than to next '>' as stated here---+
> > (replace-match "perka" nil nil nil 1))
> > )
>
> Regular expressions matches the MAXIMUM possible string. If your search
> was not limited to 400 characters, Your expression would have taken
> from the 1st "Target: <" up to the last ">" in your file.
>
Hi Ehud,
Thanks a lot for your answer.
However I must assert that your conclusions are wrong.
It's true that the '*' is very greedy and devours as much as he can,
but he cannot go further than to the next '>', that is defined in
the search string. (See above) I have verified this very carefully.
Your suggested [^>] I have already tried numerous times,
and in this case it is 100% equivalent to the original '.*'
Thanks,
Jonas Järneström