BEA Logo BEA Tuxedo Release 7.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   Tuxedo Doc Home   |   Reference   |   Topic List   |   Previous   |   Next   |   Contents

   BEA Tuxedo Command Reference

rex(1)

Name

rex - off-line regular expression compiler and tester

Synopsis

Compiling:

rex pattern_file C_file 

Testing:

rex pattern [file . . . ]

Description

When invoked without arguments, rex reads regular expressions from the standard input and writes initialized character arrays to the standard output. Normally, the output is included in a C program to preclude the need for calling recomp(). This saves on both execution time and program size. The command rex compiles the regular expressions on the standard input (normally redirected from an input file) and writes the output to the standard output (normally redirected to an output file).

The input file may contain several patterns, each of the following form.

name string [string . . .]

Here name is the C name to be used for the output array and string is the regular expression enclosed with double quotes. Where more than one string follows a name they are concatenated into one string. (Multiple strings are strictly a formatting convenience.) If double quotes occur in the pattern they need to be preceded by a backslash.

The output may be included in a C program or compiled and later loaded. In the C program that uses the rex output, rematch(abc,line,0) applies the regular expression named abc to line.

The following is a sample input file.

cname   "[a-zA-Z_][a-(3c)-Z0-9_]*" 

tn "\\\\(([0-9]{3})$0\\\\)"
"([0-9]{3})$1"
"-"
"([0-9]{4})$2"

Here is the corresponding output.

/* pattern: "[a-aA-Z_][a-zA-Z0-9_]*" */ 
char cname[] = {
040,0,0206,012,0,0210,0141,0172,0210,0101,0132,0137,
... };

/* pattern: "\\\\(([0-9]{3})$0\\\\)([0-9]{3})$1-([0-9]{4})$2" */
char tn[] = {
063,0,050,0202,0225,013,0,03,0206,06,0,0210,060,071,
... };

rex can be used to try patterns against test data by invoking it with one or more arguments. The first argument is taken as a pattern (regular expression) to be applied to each line of the files whose names are mentioned in the remaining arguments. If no filename arguments are given the standard input is used. The special filename, -, may be used as an argument to refer to the standard input.

When matching text is found, the line containing the match is printed and the matching portion of the line is underlined. In addition, any text extracted for specified sub-patterns is printed on separate line(s).

For example, the command

rex '(^| )([0-9]+)$0(|$)'

with input

... or 200 programmers in one week.
This sentense has 3 erors.
I need 12 bad men.

produces

... or 200 programmers in one week.
-----
$0 = \Q200'

This sentense has 3 erors.
---
$0 = \Q3'

I need 12 bad men.
----
$0 = \Q12'

Diagnostics

rex prints the associated error messages for errors returned from recomp() or rematch() (see recomp, rematch(3c)). Other errors include file open errors, argument errors, and so on, and are self-explanatory.

See Also

recomp, rematch(3c)