Xref: utzoo gnu.emacs.help:751 comp.emacs:9845 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!unipalm.co.uk!niall From: niall@unipalm.co.uk (Niall Mansfield) Newsgroups: gnu.emacs.help,comp.emacs Subject: an exciting replace-regexp feature Message-ID: <9101071057.AA00941@unipalm.co.uk> Date: 7 Jan 91 10:57:02 GMT Sender: daemon@tut.cis.ohio-state.edu Reply-To: niall@unipalm.co.uk Followup-To: gnu.emacs.help Organization: Gatewayed from the GNU Project mailing list help-gnu-emacs@prep.ai.mit.edu Lines: 37 In most editors which support regular expressions, replace regular expression "^." "" strips off the first character of each line. In Emacs, the effect is dramatically different: it removes everything from your file except the newlines! Any fixes? (I find this is a real problem when writing Emacs lisp programs -- to strip off stuff from the beginning of lines, even when you what's there, is dangerous. E.g. you might think that replace-regexp "^\t\t" "" will safely remove two leading tabs, but it will damage lines which begin with four tabs, six tabs, etc. The messy way out is to use a real newline character instead of the "^" metacharacter, as in replace-regexp "\n\t\t" "\n" but then you need special-casing to handle the first line of the file). [ *** Please reply direct -- I'm not on the list. ***] Regards, Niall -------------------------------------------------------------------- Unipalm XTech niall@unipalm.co.uk 145 St. Neots Road tel: +44 954 211 797 or Hardwick fax: +44 954 211 244 niall@unipalm.uucp Cambridge CB3 7QJ England