glenda.party
term% ls -F
term% cat index.txt
REGEXP(3)                  Library Functions Manual                  REGEXP(3)



NAME
       regcomp, regexec, regsub, regerror - regular expression handler

SYNOPSIS
       #include <regexp.h>

       regexp *regcomp(exp)
       char *exp;

       int regexec(prog, string)
       struct regexp *prog;
       char *string;

       regsub(prog, source, dest)
       struct regexp *prog;
       char *source;
       char *dest;

       regerror(msg)
       char *msg;

DESCRIPTION
       Regcomp compiles an egrep(1)-styleregularexpressionandreturns a pointer
       to an object with the following structure.  The object is allocated  by
       malloc(2) and may be released by free.

              /* Copyright (C) 1996-2023 Free Software Foundation, Inc.
                 This file is part of the GNU C Library.

                 The GNU C Library is free software; you can redistribute it and/or
                 modify it under the terms of the GNU Lesser General Public
                 License as published by the Free Software Foundation; either
                 version 2.1 of the License, or (at your option) any later version.

                 The GNU C Library is distributed in the hope that it will be useful,
                 but WITHOUT ANY WARRANTY; without even the implied warranty of
                 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                 Lesser General Public License for more details.

                 You should have received a copy of the GNU Lesser General Public
                 License along with the GNU C Library; if not, see
                 <https://www.gnu.org/licenses/>.  */

              #ifndef _REGEXP_H
              #define _REGEXP_H   1

              /* The contents of this header file were originally standardized in
                 the Single Unix Specification, Issue 3 (1992).  In Issue 4 (1994)
                 the header was marked as TO BE WITHDRAWN, and new applications
                 were encouraged to use <regex.h> instead.  It was officially
                 withdrawn from the standard in Issue 6 (aka POSIX.1-2001).

                 The GNU C Library provided this header through version 2.22. */

              #error "The GNU C Library no longer implements <regexp.h>."
              #error "Please update your code to use <regex.h> instead (no trailing 'p')."

              #endif /* regexp.h */

       Startp[n] points to the first character of the substring of string that
       matches the nth parenthesized subexpression (the  subexpression  intro‐
       duced  by the nth left parenthesis).  Endp[n] points to the first char‐
       acter following that substring.  The character array  program  contains
       the compiled form of the regular expression.

       Regexec  matches  a null-terminated string against the compiled regular
       expression in prog.  If it matches, regexec returns  a  non-zero  value
       and fills in the startp and endp fields to describe the match, in which
       `*', `+', and `?' matches are extended as far as possible.  By  conven‐
       tion,  startp[0]  and  endp[0]  refer to the substring that matches the
       complete regular expression.

       Regsub places in dest a substitution instance of source in the  context
       of the last regexec performed using prog.  Each instance of `\n', where
       n is a digit, is replaced by the  string  delimited  by  startp[n]  and
       endp[n].   Each  instance of `&' is replaced by the string delimited by
       startp [0] and endp [0].  The result is placed in the area  pointed  to
       by dest .

       Regerror,  called whenever an error is detected in regcomp, regexec, or
       regsub, writes the string msg on the standard  error  file  and  exits.
       Regerror can be replaced to perform special error processing.

DIAGNOSTICS
       Regcomp  returns 0 for an illegal expression or other failure.  Regexec
       returns 0 if string is not accepted.

SEE ALSO
       egrep(1), expr(1)



                                                                     REGEXP(3)