Thread View: news.software.readers
8 messages
8 total messages
Started by Jeremy Mathers
Tue, 27 Dec 1994 19:34
rn/trn: Help! Where are the regexps documented?
Author: Jeremy Mathers
Date: Tue, 27 Dec 1994 19:34
Date: Tue, 27 Dec 1994 19:34
21 lines
1777 bytes
1777 bytes
I just finished reading the trn FAQ - it does not cover what I need.
Exists there complete documentation for the reg exp parser used in trn (3.5) ?
Given that no two implementations of reg exps are the same (and it seems
that rarely is one ever a subset of another...), it does not do for the
trn man page to say, "like in ed(1) except for..."
In particular, I could not get the [re]\{n,m\} syntax to work, yet man ed
clearly lists this as a legal construct. I.e., doing: /.\{1,5\}
ought to pick up all threads whose subject contain a string of length 1
through 5 - that is, all threads (except possibly nullnamed ones). Yet
it consistently gets nothing.
************************************************************************
The Zapruder film was a snuff film.
- pynq@quads.uchicago.edu, who is still costing the net
hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer
Re: rn/trn: Help! Where are the regexps documented?
Author: Peter Kappesser
Date: Thu, 29 Dec 1994 08:12
Date: Thu, 29 Dec 1994 08:12
29 lines
2382 bytes
2382 bytes
Recently in news.software.readers, pynq@midway.uchicago.edu wrote:
>Exists there complete documentation for the reg exp parser used in trn (3.5) ?
>
>Given that no two implementations of reg exps are the same (and it seems
>that rarely is one ever a subset of another...), it does not do for the
>trn man page to say, "like in ed(1) except for..."
I can't help you on the documentation, except to note that the man page uses
the phrase "such as those used by ed(1)" -- I infer this means only similar
to, and not a rigorous implementation. For one thing, the regexps in trn are
case insensitive, and anchoring doesn't seem to work. The section in the man
page apparently indicates that the special constructs listed there are the
only ones usable.
>In particular, I could not get the [re]\{n,m\} syntax to work, yet man ed
>clearly lists this as a legal construct. I.e., doing: /.\{1,5\}
>ought to pick up all threads whose subject contain a string of length 1
>through 5 - that is, all threads (except possibly nullnamed ones). Yet
>it consistently gets nothing.
Well, let's go at it from a different direction: What are you trying to
select or kill? Maybe you can get at it on a different header line, or work
something tricky with a shell-escape command. If you're selectively saving
stuff, I've had success by piping articles to scripts I've written; the
scripts examine the articles more fully, and decide whether to save or
ignore them.
--
pjkappes@mailbox.syr.edu (Peter Kappesser)
Re: rn/trn: Help! Where are the regexps documented?
Author: Jeremy Mathers
Date: Thu, 29 Dec 1994 22:26
Date: Thu, 29 Dec 1994 22:26
56 lines
3228 bytes
3228 bytes
In article <3dtr0h$h2h@newstand.syr.edu>,
Peter Kappesser <pjkappes@mailbox.syr.edu> wrote:
..
>the phrase "such as those used by ed(1)" -- I infer this means only similar
>to, and not a rigorous implementation. For one thing, the regexps in trn are
>case insensitive, and anchoring doesn't seem to work. The section in the man
>page apparently indicates that the special constructs listed there are the
>only ones usable.
Yes. This is a pretty ugly situation. I wonder why they don't just do
full blown regular expressions. (Clearly, they do not...)
The real point is that I'd just like to be able to get the straight poop
on it.
>Well, let's go at it from a different direction: What are you trying to
>select or kill? Maybe you can get at it on a different header line, or work
>something tricky with a shell-escape command. If you're selectively saving
>stuff, I've had success by piping articles to scripts I've written; the
>scripts examine the articles more fully, and decide whether to save or
>ignore them.
Well, obviously, my example is contrived to illustrate the point.
Here's what I'm really trying to do. In certain newsgroups, the only
articles worth reading are the long ones. You want to kill all the
articles that are less than a certain length. The following code works
fine for me:
/\ .$/Hlines::=j
/\ ..$/Hlines::=j
What this does is kills any article that contains a Lines: header with
less than 3 characters after it. (Which results in all articles less
than 100 lines being discarded.)
As I say, it works just fine, but it seems ugly. I'd like to recode it as:
/\ .\{1,\2}$/Hlines::=j
Just an ego thing; you know how it is...
************************************************************************
"We trained hard -- but it seemed that every time we were
beginning to form into teams, we would be reorganized. I
was to learn later in life that we tend to meet any new
situation by reorganizing. And what a wonderful method it
can be for creating the illusion of progress while producing
confusion, inefficiency, and demoralization."
-- Gaius Petronius Arbiter --
(First Century)
- pynq@quads.uchicago.edu, who is still costing the net
hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer
Re: rn/trn: Help! Where are the regexps documented?
Author: lvirden
Date: Fri, 30 Dec 1994 23:28
Date: Fri, 30 Dec 1994 23:28
10 lines
1408 bytes
1408 bytes
I have started writing up some doc on this - unfortunately what you are wanting trn does not yet support. I will post when/if I get the motivation, time, and will power to finish. If I only had a laptop to do my editing, it would be so much easier. -- :s Great net resources sought... :s Larry W. Virden INET: larry.virden@cas.org :s <URL:http://www-bprc.mps.ohio-state.edu/cgi-bin/hpp?lvirden_sig.html> The task of an educator should be to irrigate the desert not clear the forest.
Re: rn/trn: Help! Where are the regexps documented?
Author: Wayne Davison
Date: Wed, 04 Jan 1995 02:01
Date: Wed, 04 Jan 1995 02:01
21 lines
1497 bytes
1497 bytes
According to Jeremy Mathers <pynq@midway.uchicago.edu>:
> Exists there complete documentation for the reg exp parser used in
> trn (3.5) ?
No, I guess Larry Wall figured this would be a neat puzzle for the
user to have fun with, and I haven't ever gotten the urge to write
up a doc on it.
> In particular, I could not get the [re]\{n,m\} syntax to work
As you've discovered, this doesn't work. One thing you might try
is something like: /^.$\|^..$\|^...$\|^....$\|^.....$/ to match
any string from 1 to 5 bytes long (the \| operator allows multiple
regexps to be compiled, but (unfortunately) doesn't support being
used inside of a \(\) expression).
If someone knows of a good regex package that I can distribute with
trn, let me know.
--
Wayne Davison
davison@borland.com
Draft description of trn regexp (Was: Re: rn/trn: Help! Where are the regexps documented?)
Author: lvirden
Date: Wed, 04 Jan 1995 11:12
Date: Wed, 04 Jan 1995 11:12
156 lines
7880 bytes
7880 bytes
I am hoping to get email comments on the following document, which attempts
to describe the regular expressions supported by trn 3.6. I may see
your posted replies, but to be certain, email me as well.
I am sorry about the terminology, but it is patterned after the terminology
used in other Unix man pages to attempt some sort of consistency.
Draft description of TRN 3.6 regular expressions.
Date: 01/04/95
Author: Larry W. Virden and many Unix man page writers
Version: 0.01
TRN regular expressions:
A regular expression (RE) is a way of describing patterns which one wants to
use for searching. Most commonly these are used in the KILL file
to match articles for junking or selection for reading or passing on
to other programs.
One character REs are:
1. Anything other than the special characters about to be described
will result in a RE that matches itself.
2. A backslash (\) followed by any of the special character is
a one-character RE that matches the special character
itself. The special characters are:
a. ., *, [, and \ (period, asterisk, left square
bracket, and backslash, respectively), which
are always special, except when they appear
within square brackets ([]; see 1.4 below).
b. ^ (caret or circumflex), which is special at
the beginning of an entire RE (see 4.1 and 4.3
below), or when it immediately follows the left
of a pair of square brackets ([]) (see 1.4
below).
c. $ (dollar sign), which is special at the end of
an entire RE (see 4.2 below).
d. The slash is used to delimiate the entire RE.
1.3 A period (.) is a one-character RE that matches any
character except new-line.
1.4 A non-empty string of characters enclosed in square
brackets ([]) is a one-character RE that matches any
one character in that string. If, however, the first
character of the string is a circumflex (^), the
one-character RE matches any character except new-
line and the remaining characters in the string. The
^ has this special meaning only if it occurs first in
the string. The minus (-) may be used to indicate a
range of consecutive characters; for example, [0 - 9]
is equivalent to [0123456789]. The - loses this spe-
cial meaning if it occurs first (after an initial ^,
if any) or last in the string. The right square
bracket (]) does not terminate such a string when it
is the first character within it (after an initial ^,
if any); for example, []a-f] matches either a right
square bracket (]) or one of the ASCII letters a
through f inclusive. The four characters listed in
1.2.a above stand for themselves within such a string
of characters.
The following are the rules governing multiple character REs.
2.1 A one-character RE is a RE that matches whatever the
one-character RE matches.
2.2 A one-character RE followed by an asterisk (*) is a
RE that matches zero or more occurrences of the one-
character RE. If there is any choice, the longest
leftmost string that permits a match is chosen.
2.3 A one-character RE followed by \{m\}, \{m,\}, or
\{m,n\} is a RE that matches a range of occurrences
of the one-character RE. The values of m and n must
be non-negative integers less than 256; \{m\} matches
exactly m occurrences; \{m,\} matches at least m
occurrences; \{m,n\} matches any number of
occurrences between m and n inclusive. Whenever a
choice exists, the RE matches as many occurrences as
possible.
2.4 The concatenation of REs is a RE that matches the
concatenation of the strings matched by each com-
ponent of the RE.
2.5 A RE enclosed between the character sequences \( and
\) is a RE that matches whatever the unadorned RE
matches.
2.6 The expression \n matches the same string of characters
as was matched by an expression enclosed between \(
and \) earlier in the same RE. Here n is a single digit;
the sub-expression specified is that beginning with the
n-th occurrence of \( counting from the left. For
example, the expression ^\(.*\)\1$ matches a line
consisting of two repeated appearances of the same
string. Note that \0 matches whatever the last
\) matched.
A RE may be constrained to match words.
3.1 \b constrains a RE to match the beginning of a string
or to follow a character that is not a digit, under-
score, or letter. The first character matching the
RE must be a digit, underscore, or letter.
3.2 \B constrains a RE to match the beginning of a string
or to follow a character that is a digit, underscore,
or letter, and which is not the beginning of a string.
3.3 \w constrains a RE to match the beginning of a string
or to follow a character that is not a digit
or letter. The first character matching the
RE must be a digit or letter.
3.4 \W constrains a RE to match the beginning of a string
or to follow a character that is a digit
or letter and which is not the beginning of a string.
An entire RE may be constrained to match only an initial
segment or final segment of a line (or both).
4.1 A circumflex (^) at the beginning of an entire RE
constrains that RE to match an initial segment of a
line.
4.2 A dollar sign ($) at the end of an entire RE con-
strains that RE to match a final segment of a line.
4.3 The construction ^entire RE$ constrains the entire RE
to match the entire line.
You can express a series of REs.
5.1 Up to 10 alternatives may given in a pattern,
separated by \|, with the caveat that \( ... \| ... \)
is illegal.
Also, trn folds the case of REs by default, this can be overridden in
kill file processing by the c option.
--
:s Great net resources sought...
:s Larry W. Virden INET: larry.virden@cas.org
:s <URL:http://www-bprc.mps.ohio-state.edu/cgi-bin/hpp?lvirden_sig.html>
The task of an educator should be to irrigate the desert not clear the forest.
Re: rn/trn: Help! Where are the regexps documented?
Author: Jeremy Mathers
Date: Wed, 04 Jan 1995 23:07
Date: Wed, 04 Jan 1995 23:07
16 lines
1492 bytes
1492 bytes
In article <D1uyzA.2zo@borland.com>, Wayne Davison <davison@borland.com> wrote: .. >If someone knows of a good regex package that I can distribute with >trn, let me know. Isn't there one by Henry Spencer (author of AWF, among other wonderous things) that is PD and has been used in several people's versions of AWK and such? I'd look into it. ************************************************************************ Serving coffee on aircraft causes turbulence. - pynq@quads.uchicago.edu, who is still costing the net hundreds, if not thousands, of dollars, every time he posts - ************************************************************************ rwvpf wpnrrj ibf ijrfer
Re: rn/trn: Help! Where are the regexps documented?
Author: lvirden
Date: Thu, 05 Jan 1995 10:33
Date: Thu, 05 Jan 1995 10:33
10 lines
1366 bytes
1366 bytes
Henry's package doesn't do range regular expressions. Also note that due to the GNU copyleft, the gnu regexp is out as well apparently. I wonder if there would be a way to patch Perl 5 into trn. -- :s Great net resources sought... :s Larry W. Virden INET: larry.virden@cas.org :s <URL:http://www-bprc.mps.ohio-state.edu/cgi-bin/hpp?lvirden_sig.html> The task of an educator should be to irrigate the desert not clear the forest.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads