🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #31315

Re: [slrn] Regexp syntax in rc file?

#31315
From: John E. Davis
Date: Fri, 14 Feb 1997 00:00
133 lines
6489 bytes
On 13 Feb 1997 16:31:27 GMT, Ian T Zimmerman <itz@nojunk.rahul.net>
wrote:
>Hmmm...I take it this means the \( \) syntax is simply not there
>yet...but then, what is the following doing in slregexp.c?
>
>/* ... */
>
>#define OPAREN 7		       /* \( */
>#define CPAREN 0x8		       /* \) */

S-Lang regular expressions support constructs such as:

    \([a-z]\)\1

where \1 refers to the text matched by the regular expression enclosed
in \(...\).  The \| type constructions are not supported.  I wrote the
S-Lang regular expression package based on an Ultrix man page where there
was no mention of the \| construct.

The S-Lang regular expressions are documented as part of the 'rgrep'
recursive grep program that is distributed with jed.  From its usage:

Usage: rgrep [options..] pattern [files ...]
Options:
  -?        additional help (use '-?' to avoid shell expansion on some systems)
  -c        count matches
  -h        highlight match (ANSI compatable terminal assumed)
  -H        Output match instead of entire line containing match
  -i        ignore case
  -l        list filename only
  -n        print line number of match
  -F        follow links
  -r        recursively scan through directory tree
  -N        Do NOT perform a recursive search
  -B        If file looks like a binary one, skip it.
  -R 'pat'  like '-r' except that only those files matching 'pat' are checked
  -v        print only lines that do NOT match the specified pattern
  -x 'ext'  checks only files with extension given by 'ext'.
  -D        Print all directories that would be searched.  This option is for
             debugging purposes only.  No file is grepped with this option.
  -W'len'   lines are 'len' characters long (not newline terminated).
  --version Print version
  --help    Print this help

'pattern' is a valid 'ex' type of regular expression.  See the man page for ex.
It is best enclosed in single quotes to avoid shell expansion.

Supported Regular Expressions:
   .                  match any character except newline
   \d                match any digit
   \e                match ESC char
   *                  matches zero or more occurences of previous RE
   +                  matches one or more occurences of previous RE
   ?                  matches zero or one occurence of previous RE
   ^                  matches beginning of line
   $                  matches end of line
   [ ... ]            matches any single character between brackets.
                      For example, [-02468] matches `-' or any even digit.
		      and [-0-9a-z] matches `-' and any digit between 0 and 9
		      as well as letters a through z.
   \<                Match the beginning of a word.
   \>                Match the end of a word.
   \{ ... \}
   \( ... \)
   \1, \2, ..., \9    matches match specified by nth \( ... \) expression.
                      For example, '\([ \t][a-zA-Z]+\)\1[ \t]' matches any
		      word repeated consecutively.
Examples:

 Look in all files with a 'c' extension in current directory and all its
 subdirectories looking for matches of 'int ' at the beginning of a line,
 printing the line containing the match with its line number: (two methods)
    rgrep -n -R '*.c' '^int ' .
    rgrep -n -x c '^int ' .

 Highlight all matches of repeated words in file 'paper.tex':
    rgrep -h '\<\(silly\)\>[ \t]+\<\1\>' paper.tex

 Search through all files EXCEPT .o and .a file below /usr/src/linux looking
 for the string 'mouse' without regard to case:
    rgrep -i -R '*.[^ao]' mouse /usr/src/linux

 Search a fixed record length FITS file for the keyword EXTNAME:
    rgrep -W80 ^EXTNAME file.fits
   (Note that the regular expression '^[A-Z]+' will dump all fits headers.)
   
Supported Regular Expressions:
   .                  match any character except newline
   \d                match any digit
   \e                match ESC char
   *                  matches zero or more occurences of previous RE
   +                  matches one or more occurences of previous RE
   ?                  matches zero or one occurence of previous RE
   ^                  matches beginning of line
   $                  matches end of line
   [ ... ]            matches any single character between brackets.
                      For example, [-02468] matches `-' or any even digit.
		      and [-0-9a-z] matches `-' and any digit between 0 and 9
		      as well as letters a through z.
   \<                Match the beginning of a word.
   \>                Match the end of a word.
   \{ ... \}
   \( ... \)
   \1, \2, ..., \9    matches match specified by nth \( ... \) expression.
                      For example, '\([ \t][a-zA-Z]+\)\1[ \t]' matches any
		      word repeated consecutively.
Examples:

 Look in all files with a 'c' extension in current directory and all its
 subdirectories looking for matches of 'int ' at the beginning of a line,
 printing the line containing the match with its line number: (two methods)
    rgrep -n -R '*.c' '^int ' .
    rgrep -n -x c '^int ' .

 Highlight all matches of repeated words in file 'paper.tex':
    rgrep -h '\<\(silly\)\>[ \t]+\<\1\>' paper.tex

 Search through all files EXCEPT .o and .a file below /usr/src/linux looking
 for the string 'mouse' without regard to case:
    rgrep -i -R '*.[^ao]' mouse /usr/src/linux

 Search a fixed record length FITS file for the keyword EXTNAME:
    rgrep -W80 ^EXTNAME file.fits
   (Note that the regular expression '^[A-Z]+' will dump all fits headers.)
   

-- 
John E. Davis                   Center for Space Research/AXAF Science Center
617-258-8119                    MIT 37-662c, Cambridge, MA 02139
http://space.mit.edu/~davis

Technical Details
Message-ID: <slrn5g81gd.gfg.davis@aluche.mit.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
References: <slrn5g1q7t.gc4.itz@kronstadt.rahul.net> <slrn5g41sd.rr4.davis@mygir.davis.net> <slrn5g6geu.23h.itz@kronstadt.rahul.net>

Show Full Headers
Complete Article Headers
Message-ID: <slrn5g81gd.gfg.davis@aluche.mit.edu>
Subject: Re: [slrn] Regexp syntax in rc file?
Date: Fri, 14 Feb 1997 00:00:00 +0000
From: davis@space.mit.edu (John E. Davis)
References: <slrn5g1q7t.gc4.itz@kronstadt.rahul.net> <slrn5g41sd.rr4.davis@mygir.davis.net> <slrn5g6geu.23h.itz@kronstadt.rahul.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
X-Deja-AN: 218691129
Organization: Center for Space Research
Reply-To: davis@space.mit.edu
Newsgroups: news.software.readers