regerror()

Updated: April 19, 2023

Explain a regular expression error code

Synopsis:

#include <regex.h>

size_t regerror( int err, 
                 const regex_t * reg,
                 char * buf, 
                 size_t len );

Arguments:

err
The value returned by a previous call to regcomp() or regexec().
reg
A pointer to the regex_t object for the regular expression that you provided to the failed call to regcomp() or regexec().
buf
A pointer to a buffer where the function can store the explanation.
len
The length of the buffer, in characters.

Library:

libregex

Use the -l regex option to qcc to link against this library.

Description:

The regerror() function provides a string explaining an error code returned by regcomp() or regexec(). The string is copied into buf for up to len characters.

Returns:

The number of characters copied into the buffer.

Examples:

See regcomp().

Classification:

POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

Contributing author:

Henry Spencer. For license information, see Licensing information in Typographical Conventions, Support, and Licensing.