doug@hcr.UUCP (Doug Moen) (10/31/83)
How would you solve the following problem: I am in the editor, and would like to delete all lines within a specified range that contain a match for regular expression /A/, but *not* for regular expression /B/. For 'editor', substitute the name of your favourite text editor. The only way I can think of doing this in ed (or ex) is by typing <m>,<n> g/A/ .v/B/ d unfortunately, nested global commands are forbidden in ed and its relatives. Does *your* favourite editor provide a reasonable way to do this? If so, how, and where can I get a copy? Doug Moen {decvax,watmath,utzoo,cbosgd,ihnp4,logica,research}!hcr!doug
dave@utcsrgv.UUCP (Dave Sherman) (10/31/83)
hcr!doug asks how to get an editor to delete every line containing A except for those which also contain B. ed will do it: g/B/s/A/ZZZZZ/g g/A/d g/ZZZZZ/s//A/g Presto. It's a little ugly, but it works, and quickly too. Pick your favourite string for ZZZZZ. It should of course be something that doesn't occur elsewhere in the file, but unless you're dealing with random ASCII text, that's not hard to find. If you have qed and need this often enough, it can easily be automated into a string register or buffer. Dave Sherman Toronto -- {allegra,cornell,decvax,ihnp4,linus,utzoo}!utcsrgv!dave
guidi@pegasus.UUCP (11/05/83)
How to change every A in a file except for those lines containing a B? Using 'ed': v/B/s/A/...../ where A and B are reg exp as usual.