regex.h(0P)
πΈ PROLOG πΈ
okay bestie, before literally anything else β this manual page is part of the POSIX Programmer's Manual. π
but real talk: the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for details of Linux behavior, fr), or the interface may not be implemented on Linux at all. π imagine.
π NAME π
regex.h β regular expression matching types
short, sweet, iconic, no notes. β¨
π¦ SYNOPSIS π¦
#include <regex.h>
that's the whole thing. she's lowkey minimal. π«Ά
β¨ DESCRIPTION β¨
so the <regex.h> header shall define the structures and symbolic constants used by the regcomp(), regexec(), regerror(), and regfree() functions. the whole squad, no cap. π₯
π the regex_t structure
The <regex.h> header shall define the regex_t structure type, which shall include at least this member:
size_t re_nsub Number of parenthesized subexpressions.
(that's the number of parenthesized subexpressions, iykyk π)
π the size_t type
The <regex.h> header shall define the size_t type as described in <sys/types.h>. go read that one too, bestie.
π§ the regoff_t type
The <regex.h> header shall define the regoff_t type as a signed integer type that can hold the largest value that can be stored in either a ptrdiff_t type or a ssize_t type. big enough for whatever you're throwing at it. πͺ
π the regmatch_t structure
The <regex.h> header shall define the regmatch_t structure type, which shall include at least these members:
regoff_t rm_so Byte offset from start of string
to start of substring.
regoff_t rm_eo Byte offset from start of string of the
first character after the end of substring.
so rm_so is where the substring starts and rm_eo is the byte right after it ends. the two of them are giving buddy-system energy. π
π symbolic constants for the cflags parameter of regcomp()
The <regex.h> header shall define these:
REG_EXTENDEDβ Use Extended Regular Expressions.REG_ICASEβ Ignore case in match.REG_NOSUBβ Report only success or fail inregexec().REG_NEWLINEβ Change the handling of<newline>.
β symbolic constants for the eflags parameter of regexec()
The <regex.h> header shall define these:
REG_NOTBOLβ The<circumflex>character ('^'), when taken as a special character, does not match the beginning of string.REG_NOTEOLβ The<dollar-sign>('$'), when taken as a special character, does not match the end of string.
π symbolic constants as error return values
The <regex.h> header shall define these:
REG_NOMATCHβregexec()failed to match.REG_BADPATβ Invalid regular expression.REG_ECOLLATEβ Invalid collating element referenced.REG_ECTYPEβ Invalid character class type referenced.REG_EESCAPEβ Trailing<backslash>character in pattern.REG_ESUBREGβ Number in\digitinvalid or in error.REG_EBRACKβ[]imbalance.REG_EPARENβ\(\)or()imbalance.REG_EBRACEβ\{\}imbalance.REG_BADBRβ Content of\{\}invalid: not a number, number too large, more than two numbers, first larger than second.REG_ERANGEβ Invalid endpoint in range expression.REG_ESPACEβ Out of memory. πREG_BADRPTβ'?','*', or'+'not preceded by valid regular expression.
π«Ά the functions
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.
int regcomp(regex_t *restrict, const char *restrict, int);
size_t regerror(int, const regex_t *restrict, char *restrict, size_t);
int regexec(const regex_t *restrict, const char *restrict, size_t,
regmatch_t [restrict], int);
void regfree(regex_t *);
and one more thing π
The implementation may define additional macros or constants using names beginning with REG_.
The following sections are informative.
π· APPLICATION USAGE π·
None.
literally nothing. she said no thoughts, head empty. π
πΊ RATIONALE πΊ
None.
also nothing. π
π¦ FUTURE DIRECTIONS π¦
None.
(the future is, apparently, unwritten. periodt.)
π SEE ALSO π
<sys_types.h>- The System Interfaces volume of POSIX.1β2017,
regcomp()
π COPYRIGHT π
okay so legally speaking, here's the whole notice, keeping it 100% intact because lawyers are not a vibe to mess with:
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π¦ this one came to you courtesy of IEEE/The Open Group, dated 2017 β mwah, thanks for the lore, now go match some regexes responsibly. πβ¨π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms