re_comp(3C)


re_comp, re_exec -- regular expression handler

Synopsis

   char *re_comp(char *s);
   

re_exec(char *s);

Description

The re_comp function converts a regular expression string (RE) into an internal form suitable for pattern matching.

The re_exec function compares the string pointed to by the string argument with the last regular expression passed to re_comp.

If re_comp is called with a null pointer argument, the current regular expression remains unchanged. Strings passed to both re_comp and re_exec must b terminated by a NULL byte, and may include newline characters.

The strings passed to both re_comp and re_exec may have trailing or embedded NEWLINE characters; they are terminated by null characters. The regular expressions recognized are described in the manual page entry for ed(1), given the above difference.

Return values

The re_comp function returns a NULL pointer when the string pointed to by the string argument is successfully converted. Otherwise, a pointer to one of the following strings is returned:
   No previous regular expression
   Regular expression too long
   unmatched \(
   missing ]
   too many \(\) pairs
   unmatched \)

Upon successful completion, re_exec returns 1 if string matches the last compiled regular expression. Otherwise, re_exec returns 0 if string fails to match the last compiled regular expression, and -1 if the compiled regular expression is invalid (indicating an internal error). characters; they are terminated by null characters. The regular expressions recognized are described in the manual page entry for ed(1), given the above difference.

Compatibility

These functions were added to X/Open System Interfaces and Headers, Issue 4, Version 2, but are labelled to be withdrawn in a future issue. For portability, the routines documented on regcomp(3C) are preferred.

References

ed(1), ex(1), grep(1), regcmp(1), regcmp(3G), regcomp(3C), regexp(5), regexpr(3G)

Standards conformance

These routines conform to X/Open System Interfaces and Headers, Issue 4, Version 2.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004