[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

re_comp or re_exec Subroutine

Purpose

Regular expression handler.

Library

Standard C Library (libc.a)

Syntax

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

Description

Attention: Do not use the re_comp or re_exec subroutine in a multithreaded environment.

The re_comp subroutine compiles a string into an internal form suitable for pattern matching. The re_exec subroutine checks the argument string against the last string passed to the re_comp subroutine.

The re_comp subroutine returns 0 if the string pointed to by the String parameter was compiled successfully; otherwise a string containing an error message is returned. If the re_comp subroutine is passed 0 or a null string, it returns without changing the currently compiled regular expression.

The re_exec subroutine returns 1 if the string pointed to by the String parameter matches the last compiled regular expression, 0 if the string pointed to by the String parameter failed to match the last compiled regular expression, and -1 if the compiled regular expression was invalid (indicating an internal error).

The strings passed to both re_comp and re_exec subroutines may have trailing or embedded newline characters; they are terminated by nulls. The regular expressions recognized are described in the manual entry for the ed command, given the above difference.

Parameters

String Points to a string that is to be matched or compiled.

Return Values

If an error occurs, the re_exec subroutine returns a -1, while the re_comp subroutine returns one of the following strings:

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The compile, step, or advance subroutine, regcmp or regex subroutine.

The ed command, sed command, grep command.

List of String Manipulation Services in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

National Language Support Overview for Programming and Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]