Patrick> I was trying to remove a leading column of '>' characters
Patrick> from some text and got some strange behavior from replace-regexp.
Patrick> I have text something like this:
>>blah blah blah
>> blah blah blah
Patrick> I wanted to remove the first '>' in each line. Thus, I did:
Patrick> (replace-regexp "^>" "")
Patrick> Instead of removing just the first '>' in each line, it removed
Patrick> the whole sequence of '>' characters. It acted as though I
Patrick> has used "^>*" for the first argument. I ended up with:
Ok, here's the deal. What emacs does is to do a re-search-forward for your
search string, deletes it, and inserts the replacement string. There goes
the "^>". Now, it repeats the re-search-forward. Lo and behold, point is
sitting just to the left of the search string "^>". It gleefully replaces
it with the replacement string, and repeats itself.
You may want to use querey-replace-regexp instead. Or do two replace-regexp
commands, the first change "^>" into something else, like "><", then do a
second replace-regexp on the new string.
--Rat PGP Public Key Block available upon request
||||| | | | | | | | | | | | | | | | | | | | | | | |||||
Love is a snowmobile racing across the tundra and then suddenly it flips over,
pinning you underneath. At night, the ice weasels come.
--Nietzsche [or Matt Groening]