Article View: comp.editors
Article #2669Re: Using regular expressions in Micro Emacs 3.10
From: Tony Mountifield
Date: Fri, 17 May 1991 09:11
Date: Fri, 17 May 1991 09:11
44 lines
2190 bytes
2190 bytes
In article <BADRI.91May14150327@elysium.warren.mentor.com> badri@warren.mentorg.com (Badri Lokanathan) writes:
-> I am running Micro Emacs 3.10 alpha on a Mac.
-> I encountered a couple of problems with the replace command:
->
-> (1) Suppose I need to do two global substitutions on a file:
-> - Insert XX at the beginning of each line
-> - delete YY at the end of each line
->
-> I set mode to MAGIC, then execute replace ^ with XX. Now when I try
-> to replace YY$ with <nothing>, I am unable to get rid of the former
-> replacement string XX.
->
-> Of course, I can always switch the order of execution, but that is not
-> the answer I am looking for :-)
You could always try replacing YY<NL> with <NL>
Or define a macro which does:
set $replace ""
and then bind that macro to an unused key such as ^_
-> (2) Is it possible to "remember" a matched pattern and interpolate it
-> into the replacement pattern (ala vi)? For those who are familiar with
-> vi, how does one achieve something like
->
-> s/\([a-z0-9]*\)_\([a-z0-9]*\)/\2_\1/
I don't think it is possible. You just have the ability to insert the
WHOLE of the matched pattern using &
-> --
-> Badri Lokanathan Go ahead, flame away.
-> badri@sdl.scs.com (or) Make my day.
-> ...!uunet!sdl!badri
Tony.
--
Tony Mountifield. | Microware Systems (UK) Ltd.
MAIL: tony@mwuk.uucp | Leylands Farm, Nobs Crook,
INET: tony%mwuk.uucp@ukc.ac.uk | Colden Common, WINCHESTER, SO21 1TH.
UUCP: ...!mcsun!ukc!mwuk!tony | Tel: 0703 601990 Fax: 0703 601991
**** OS-9, OS-9000 Real Time Systems **** MS-DOS - just say "No!" ****
Technical Details
Message-ID:
<427@mwuk.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!spool.mu.edu!uunet!mcsun!ukc!pyrltd!mwuk!tonyReferences:
<BADRI.91May14150327@elysium.warren.mentor.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!spool.mu.edu!uunet!mcsun!ukc!pyrltd!mwuk!tony From: tony@mwuk.UUCP (Tony Mountifield) Newsgroups: comp.editors Subject: Re: Using regular expressions in Micro Emacs 3.10 Message-ID: <427@mwuk.UUCP> Date: 17 May 91 09:11:22 GMT References: <BADRI.91May14150327@elysium.warren.mentor.com> Distribution: comp Organization: Microware Systems (UK) Ltd., Winchester, UK. Lines: 44