233 lines
7.0 KiB
HTML
233 lines
7.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title><regex.h></title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="<regex.h>"></a> <a name="tag_13_38"></a><!-- <regex.h> -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_13_38_01"></a>NAME</h4>
|
|
|
|
<blockquote>regex.h - regular expression matching types</blockquote>
|
|
|
|
<h4><a name="tag_13_38_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><tt>#include <regex.h></tt></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_38_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i><regex.h></i> header shall define the structures and symbolic constants used by the <a href=
|
|
"../functions/regcomp.html"><i>regcomp</i>()</a>, <a href="../functions/regexec.html"><i>regexec</i>()</a>, <a href=
|
|
"../functions/regerror.html"><i>regerror</i>()</a>, and <a href="../functions/regfree.html"><i>regfree</i>()</a> functions.</p>
|
|
|
|
<p>The structure type <b>regex_t</b> shall contain at least the following member:</p>
|
|
|
|
<pre>
|
|
<tt>size_t re_nsub </tt> Number of parenthesized subexpressions. <tt>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The type <b>size_t</b> shall be defined as described in <a href="sys/types.h.html"><i><sys/types.h></i></a> .</p>
|
|
|
|
<p>The type <b>regoff_t</b> shall be defined as a signed integer type that can hold the largest value that can be stored in either
|
|
a type <b>off_t</b> or type <b>ssize_t</b>. The structure type <b>regmatch_t</b> shall contain at least the following members:</p>
|
|
|
|
<pre>
|
|
<tt>regoff_t rm_so </tt> Byte offset from start of string <tt>
|
|
</tt> to start of substring. <tt>
|
|
regoff_t rm_eo </tt> Byte offset from start of string of the <tt>
|
|
</tt> first character after the end of substring. <tt>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>Values for the <i>cflags</i> parameter to the <a href="../functions/regcomp.html"><i>regcomp</i>()</a> function are as
|
|
follows:</p>
|
|
|
|
<dl compact>
|
|
<dt>REG_EXTENDED</dt>
|
|
|
|
<dd>Use Extended Regular Expressions.</dd>
|
|
|
|
<dt>REG_ICASE</dt>
|
|
|
|
<dd>Ignore case in match.</dd>
|
|
|
|
<dt>REG_NOSUB</dt>
|
|
|
|
<dd>Report only success or fail in <a href="../functions/regexec.html"><i>regexec</i>()</a>.</dd>
|
|
|
|
<dt>REG_NEWLINE</dt>
|
|
|
|
<dd>Change the handling of <newline>.</dd>
|
|
</dl>
|
|
|
|
<p>Values for the <i>eflags</i> parameter to the <a href="../functions/regexec.html"><i>regexec</i>()</a> function are as
|
|
follows:</p>
|
|
|
|
<dl compact>
|
|
<dt>REG_NOTBOL</dt>
|
|
|
|
<dd>The circumflex character ( <tt>'^'</tt> ), when taken as a special character, does not match the beginning of
|
|
<i>string</i>.</dd>
|
|
|
|
<dt>REG_NOTEOL</dt>
|
|
|
|
<dd>The dollar sign ( <tt>'$'</tt> ), when taken as a special character, does not match the end of <i>string</i>.</dd>
|
|
</dl>
|
|
|
|
<p>The following constants shall be defined as error return values:</p>
|
|
|
|
<dl compact>
|
|
<dt>REG_NOMATCH</dt>
|
|
|
|
<dd><a href="../functions/regexec.html"><i>regexec</i>()</a> failed to match.</dd>
|
|
|
|
<dt>REG_BADPAT</dt>
|
|
|
|
<dd>Invalid regular expression.</dd>
|
|
|
|
<dt>REG_ECOLLATE</dt>
|
|
|
|
<dd>Invalid collating element referenced.</dd>
|
|
|
|
<dt>REG_ECTYPE</dt>
|
|
|
|
<dd>Invalid character class type referenced.</dd>
|
|
|
|
<dt>REG_EESCAPE</dt>
|
|
|
|
<dd>Trailing <tt>'\'</tt> in pattern.</dd>
|
|
|
|
<dt>REG_ESUBREG</dt>
|
|
|
|
<dd>Number in \<i>digit</i> invalid or in error.</dd>
|
|
|
|
<dt>REG_EBRACK</dt>
|
|
|
|
<dd><tt>"[]"</tt> imbalance.</dd>
|
|
|
|
<dt>REG_EPAREN</dt>
|
|
|
|
<dd><tt>"\(\)"</tt> or <tt>"()"</tt> imbalance.</dd>
|
|
|
|
<dt>REG_EBRACE</dt>
|
|
|
|
<dd><tt>"\{\}"</tt> imbalance.</dd>
|
|
|
|
<dt>REG_BADBR</dt>
|
|
|
|
<dd>Content of <tt>"\{\}"</tt> invalid: not a number, number too large, more than two numbers, first larger than second.</dd>
|
|
|
|
<dt>REG_ERANGE</dt>
|
|
|
|
<dd>Invalid endpoint in range expression.</dd>
|
|
|
|
<dt>REG_ESPACE</dt>
|
|
|
|
<dd>Out of memory.</dd>
|
|
|
|
<dt>REG_BADRPT</dt>
|
|
|
|
<dd><tt>'?'</tt> , <tt>'*'</tt> , or <tt>'+'</tt> not preceded by valid regular expression.</dd>
|
|
|
|
<dt>REG_ENOSYS</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('OB')">OB</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Reserved. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
</dl>
|
|
|
|
<p>The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.</p>
|
|
|
|
<pre>
|
|
<tt>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 *);
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The implementation may define additional macros or constants using names beginning with REG_.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_13_38_04"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_38_05"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_38_06"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_38_07"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="sys/types.h.html"><i><sys/types.h></i></a> , the System Interfaces volume of IEEE Std 1003.1-2001, <a
|
|
href="../functions/regcomp.html"><i>regcomp</i>()</a>, the Shell and Utilities volume of IEEE Std 1003.1-2001</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_38_08"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4.</p>
|
|
|
|
<p>Originally derived from the ISO POSIX-2 standard.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_13_38_09"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The REG_ENOSYS constant is marked obsolescent.</p>
|
|
|
|
<p>The <b>restrict</b> keyword is added to the prototypes for <a href="../functions/regcomp.html"><i>regcomp</i>()</a>, <a href=
|
|
"../functions/regerror.html"><i>regerror</i>()</a>, and <a href="../functions/regexec.html"><i>regexec</i>()</a>.</p>
|
|
|
|
<p>A statement is added that the <b>size_t</b> type is defined as described in <a href=
|
|
"sys/types.h.html"><i><sys/types.h></i></a> .</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|