Article View: net.emacs
Article #2198Re: regular expressions and operations
From: Mike Wexler
Date: Wed, 29 Oct 1986 23:36
Date: Wed, 29 Oct 1986 23:36
81 lines
3723 bytes
3723 bytes
In article <4300002@uicsl> prestat@uicsl.UUCP writes:
>All the responses to the question about using regular
>expressions to select lines seem to be non-responsive.
Enclosed is a summary of the responses I got via e-mail summary of them
are quite helpful. BTW I have edited these.
>scott preece
>PREECE@GSWD-VMS.ARPA
-------------------------------------------------------------------------------
From: felix!hplabs!weemba@brahms.berkeley.edu (Matthew P Wiener)
(while (looking-at "regular expression") (action-1) (action 2) ...)
You can execute this without programming, by using ESC ESC to do a one-time
evaluation. If you don't know what the names associated to certain key
actions are and can't find them in the manual, look at C-h c to get the
name. Sometimes you need specific arguments for an action, C-h k or C-h f
will give you the details. Have fun.
ucbvax!brahms!weemba Matthew P Wiener/UCB Math Dept/Berkeley CA 94720
-----------------------------------------------------------------------------
From: felix!hplabs!ucbvax!phr@ernie.berkeley.edu (Paul Rubin)
>From the Emacs Info file (found by looking for "delete-matching-lines"
in the Command Index):
File: emacs Node: Other Repeating Search, Prev: Replace, Up: Search
Other Search-and-Loop Commands
==============================
Here are some other commands that find matches for a regular expression.
They all operate from point to the end of the buffer.
`M-x list-matching-lines'
Print each line that follows point and contains a match for the
specified regexp. A numeric argument specifies the number of context
lines to print before and after each matching line; the default is
none.
`M-x count-matches'
Print the number of matches following point for the specified regexp.
`M-x delete-non-matching-lines'
Delete each line that follows point and does not contain a match for
the specified regexp.
`M-x delete-matching-lines'
Delete each line that follows point and contains a match for the
specified regexp.
From: felix!trwrb!trwspp!spp2!urban (Mike Urban)
Easy. Filter the buffer through a "sed" command. As with many
Unix techniques, I haven't decided whether this method is wonderfully
elegant, or an awful kludge. It *is*, however, very useful. If you
find yourself doing it a lot, you can even have some key bound to a function
that prompts you for the sed command and does the work.
Mike Urban
-------------------------------------------------------------------------------
From: Bob Chassell <ccicpg!seismo!harvard!lmi-angel!bob>
The easiest thing to do is write a keyboard macro and then apply it
generally. Look up the online documentation with control-h i, get into
the manual and then look for regexps and for keyboard macros. (It
looks like there are a lot of nodes in the table of contents for the
manual but you can search for regexp and macro.)
Bob Chassell
--
Mike Wexler
(trwrb|scgvaxd)!felix!peregrine!mike
(714)855-3923
Technical Details
Message-ID:
<1185@peregrine.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!nike!sri-spam!sri-unix!hplabs!felix!peregrine!mikeReferences:
<1168@peregrine.UUCP> <4300002@uicsl>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!nike!sri-spam!sri-unix!hplabs!felix!peregrine!mike From: mike@peregrine.UUCP (Mike Wexler) Newsgroups: net.emacs Subject: Re: regular expressions and operations Message-ID: <1185@peregrine.UUCP> Date: Wed, 29-Oct-86 18:36:24 EST Article-I.D.: peregrin.1185 Posted: Wed Oct 29 18:36:24 1986 Date-Received: Thu, 30-Oct-86 23:23:07 EST References: <1168@peregrine.UUCP> <4300002@uicsl> Reply-To: mike@peregrine.UUCP (Mike Wexler) Organization: Peregrine Systems, Inc, Irvine Ca Lines: 81