1 2 3 4 5 6 7 8 9

Examples:
Supercomputer [13579]
[A-Z][a-z]* [^aeiou][aeiou]*

Super.*
^Once upon a time [qQ][^u]
\([0-9][0-9]*\)\2

The above work in the UNIX command line, and in vi

How about pattern matching from within a C program?

There are two useful functions in

#include <re_comp.h>

that provide the following prototype functions

char* re_comp (char*);
int re_exec (char*);

To be useful pattern matching must be very fast, so the raw text form of the regular expressions require some parsing to convert them to a more efficient representation.

It is re_comp()that does this.

The function used to actually do the matching of the regular expression pattern against the contents of the string is called re_exec().

4 February, 1998

8

Copyright University of Alberta