home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.emacs:3874 gnu.emacs.help:5188 gnu.epoch.misc:1221
- Path: sparky!uunet!spool.mu.edu!hri.com!noc.near.net!lynx!random.ccs.northeastern.edu!news
- From: ratinox@meceng.coe.northeastern.edu (Lemming Productions Present...)
- Newsgroups: comp.emacs,gnu.emacs.help,gnu.epoch.misc
- Subject: Re: strange replace-regexp behavior
- Message-ID: <RATINOX.92Dec28122732@splinter.coe.northeastern.edu>
- Date: 28 Dec 92 17:28:34 GMT
- References: <1992Dec28.133923.27974@nsisrv.gsfc.nasa.gov>
- Sender: news@random.ccs.northeastern.edu
- Organization: 3WA, Boston Office. Or Nu Meta Chi. Take your pick.
- Lines: 35
- In-Reply-To: pat@gsfc.nasa.gov's message of Mon, 28 Dec 1992 13: 39:23 GMT
- Nntp-Posting-Host: splinter.coe.northeastern.edu
- X-Posting-Software: GNUS 3.14.1 [ NNTP-based News Reader for GNU Emacs ]
- X-Signature-Virus-Protection: Version 1.51
- X-Get-A-Clue: Have two, they're small.
-
- >>>>> On Mon, 28 Dec 1992 13:39:23 GMT, pat@gsfc.nasa.gov (patrick m. ryan)
- >>>>> said:
-
- 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:
-
- >In article 999, joe@blow said:
- >>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
- ||||| | | | | | | | | | | | | | | | | | | | | | | |||||
- Northeastern's Stainless Steel Rat ratinox@meceng.coe.northeastern.edu
- 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]
-