![]() |
![]() |
![]() |
regexp [inputfile]
Once invoked, the user may interactively input a regular expression followed by a carriage return. The sample text is scanned for occurrences of the defined regular expression. Any text lines containing the matched expression are displayed on the screen; regexp differs from the UNIX grep command in that the precise locations of the matched pattern are explicitly marked. (See EXAMPLES below.) Note that only the first occurrence of a matching pattern is identified in each line of text. (This is how most software tools make use of regular expressions.)
The entire sample text file may be viewed by typing the regular
expression .*
or by simply typing a carriage return.
Viewing the sample text is helpful in identifying character-strings that are
not identified by a given regular expression.
The regexp command is terminated by typing an end-of-file marker (control-D on UNIX; control-Z on DOS or OS/2).
The regexp command implements the same regular expression features found in the UNIX awk command. This includes all so-called "extended" regular expression features with the exception of \> and \<.
Options are specified in the command line.
-h displays a help screen summarizing the command syntax
The quick brown fox jumped over the lazy dogs.
Once upon a time, long, long ago ...
It was the best of times, it was the worst of times.
The following regular expression defines any character string
beginning with the lower-case letter `b', followed by zero or
one instance of any single character, followed by a lower-case vowel.
b.?[aeiou]
Given this regular expression, the corresponding output would appear as follows:
The quick brown fox jumped over the lazy dogs.
^ ^
It was the best of times, it was the worst of times.
^^
Notice that only those text lines matching the defined regular
expression are displayed in the output.
AWK_VER
shell variable.
Available features may change depending on the version of
awk
used.
$HUMDRUM/regexp.txt.
awk (UNIX),
expr (UNIX),
patt (4),
pattern (4),
regexp (6),
sed (UNIX)