| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>xmlregexp: regular expressions handling</title> |
| <meta name="generator" content="Libxml2 devhelp stylesheet"> |
| <link rel="start" href="index.html" title="libxml2 Reference Manual"> |
| <link rel="up" href="general.html" title="API"> |
| <link rel="stylesheet" href="style.css" type="text/css"> |
| <link rel="chapter" href="general.html" title="API"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"> |
| <td><a accesskey="p" href="libxml2-xmlreader.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> |
| <td><a accesskey="u" href="general.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> |
| <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> |
| <td><a accesskey="n" href="libxml2-xmlsave.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> |
| <th width="100%" align="center">libxml2 Reference Manual</th> |
| </tr></table> |
| <h2><span class="refentrytitle">xmlregexp</span></h2> |
| <p>xmlregexp - regular expressions handling</p> |
| <p>basic API for libxml regular expressions handling used for XML Schemas and validation. </p> |
| <p>Author(s): Daniel Veillard </p> |
| <div class="refsynopsisdiv"> |
| <h2>Synopsis</h2> |
| <pre class="synopsis">typedef struct _xmlRegExecCtxt <a href="#xmlRegExecCtxt">xmlRegExecCtxt</a>; |
| typedef <a href="libxml2-xmlregexp.html#xmlRegExecCtxt">xmlRegExecCtxt</a> * <a href="#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a>; |
| typedef struct _xmlRegexp <a href="#xmlRegexp">xmlRegexp</a>; |
| typedef <a href="libxml2-xmlregexp.html#xmlRegexp">xmlRegexp</a> * <a href="#xmlRegexpPtr">xmlRegexpPtr</a>; |
| typedef void <a href="#xmlRegExecCallbacks">xmlRegExecCallbacks</a> (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * token, <br> void * transdata, <br> void * inputdata); |
| int <a href="#xmlRegExecErrInfo">xmlRegExecErrInfo</a> (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** string, <br> int * nbval, <br> int * nbneg, <br> <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** values, <br> int * terminal); |
| int <a href="#xmlRegExecNextValues">xmlRegExecNextValues</a> (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> int * nbval, <br> int * nbneg, <br> <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** values, <br> int * terminal); |
| int <a href="#xmlRegExecPushString">xmlRegExecPushString</a> (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value, <br> void * data); |
| int <a href="#xmlRegExecPushString2">xmlRegExecPushString2</a> (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value2, <br> void * data); |
| void <a href="#xmlRegFreeExecCtxt">xmlRegFreeExecCtxt</a> (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec); |
| void <a href="#xmlRegFreeRegexp">xmlRegFreeRegexp</a> (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> regexp); |
| <a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> <a href="#xmlRegNewExecCtxt">xmlRegNewExecCtxt</a> (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> comp, <br> <a href="libxml2-xmlregexp.html#xmlRegExecCallbacks">xmlRegExecCallbacks</a> callback, <br> void * data); |
| <a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> <a href="#xmlRegexpCompile">xmlRegexpCompile</a> (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * regexp); |
| int <a href="#xmlRegexpExec">xmlRegexpExec</a> (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> comp, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content); |
| int <a href="#xmlRegexpIsDeterminist">xmlRegexpIsDeterminist</a> (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> comp); |
| void <a href="#xmlRegexpPrint">xmlRegexpPrint</a> (FILE * output, <br> <a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> regexp); |
| </pre> |
| </div> |
| <div class="refsect1" lang="en"><h2>Description</h2></div> |
| <div class="refsect1" lang="en"> |
| <h2>Details</h2> |
| <div class="refsect2" lang="en"> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegExecCtxt">Structure </a>xmlRegExecCtxt</h3> |
| <pre class="programlisting">struct _xmlRegExecCtxt { |
| The content of this structure is not made public by the API. |
| } xmlRegExecCtxt; |
| </pre> |
| <p></p> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegExecCtxtPtr">Typedef </a>xmlRegExecCtxtPtr</h3> |
| <pre class="programlisting"><a href="libxml2-xmlregexp.html#xmlRegExecCtxt">xmlRegExecCtxt</a> * xmlRegExecCtxtPtr; |
| </pre> |
| <p>A libxml progressive regular expression evaluation context</p> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegexp">Structure </a>xmlRegexp</h3> |
| <pre class="programlisting">struct _xmlRegexp { |
| The content of this structure is not made public by the API. |
| } xmlRegexp; |
| </pre> |
| <p></p> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegexpPtr">Typedef </a>xmlRegexpPtr</h3> |
| <pre class="programlisting"><a href="libxml2-xmlregexp.html#xmlRegexp">xmlRegexp</a> * xmlRegexpPtr; |
| </pre> |
| <p>A libxml regular expression, they can actually be far more complex thank the POSIX regex expressions.</p> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegExecCallbacks"></a>Function type xmlRegExecCallbacks</h3> |
| <pre class="programlisting">void xmlRegExecCallbacks (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * token, <br> void * transdata, <br> void * inputdata)<br> |
| </pre> |
| <p>Callback function when doing a transition in the automata</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>exec</tt></i>:</span></td> |
| <td>the regular expression context</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>token</tt></i>:</span></td> |
| <td>the current token string</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>transdata</tt></i>:</span></td> |
| <td>transition data</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>inputdata</tt></i>:</span></td> |
| <td>input data</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegExecErrInfo"></a>xmlRegExecErrInfo ()</h3> |
| <pre class="programlisting">int xmlRegExecErrInfo (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** string, <br> int * nbval, <br> int * nbneg, <br> <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** values, <br> int * terminal)<br> |
| </pre> |
| <p>Extract error information from the regexp execution, the parameter @string will be updated with the value pushed and not accepted, the parameter @values must point to an array of @nbval string pointers on return nbval will contain the number of possible strings in that state and the @values array will be updated with them. The string values</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>exec</tt></i>:</span></td> |
| <td>a regexp execution context generating an error</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>string</tt></i>:</span></td> |
| <td>return value for the error string</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>nbval</tt></i>:</span></td> |
| <td>pointer to the number of accepted values IN/OUT</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>nbneg</tt></i>:</span></td> |
| <td>return number of negative transitions</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>values</tt></i>:</span></td> |
| <td>pointer to the array of acceptable values</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>terminal</tt></i>:</span></td> |
| <td>return value if this was a terminal state</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>will be freed with the @exec context and don't need to be deallocated. Returns: 0 in case of success or -1 in case of error.</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegExecNextValues"></a>xmlRegExecNextValues ()</h3> |
| <pre class="programlisting">int xmlRegExecNextValues (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> int * nbval, <br> int * nbneg, <br> <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> ** values, <br> int * terminal)<br> |
| </pre> |
| <p>Extract information from the regexp execution, the parameter @values must point to an array of @nbval string pointers on return nbval will contain the number of possible strings in that state and the @values array will be updated with them. The string values</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>exec</tt></i>:</span></td> |
| <td>a regexp execution context</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>nbval</tt></i>:</span></td> |
| <td>pointer to the number of accepted values IN/OUT</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>nbneg</tt></i>:</span></td> |
| <td>return number of negative transitions</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>values</tt></i>:</span></td> |
| <td>pointer to the array of acceptable values</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>terminal</tt></i>:</span></td> |
| <td>return value if this was a terminal state</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>will be freed with the @exec context and don't need to be deallocated. Returns: 0 in case of success or -1 in case of error.</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegExecPushString"></a>xmlRegExecPushString ()</h3> |
| <pre class="programlisting">int xmlRegExecPushString (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value, <br> void * data)<br> |
| </pre> |
| <p>Push one input token in the execution context</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>exec</tt></i>:</span></td> |
| <td>a regexp execution context or NULL to indicate the end</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>value</tt></i>:</span></td> |
| <td>a string token input</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>data</tt></i>:</span></td> |
| <td>data associated to the token to reuse in callbacks</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>1 if the regexp reached a final state, 0 if non-final, and a negative value in case of error.</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegExecPushString2"></a>xmlRegExecPushString2 ()</h3> |
| <pre class="programlisting">int xmlRegExecPushString2 (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * value2, <br> void * data)<br> |
| </pre> |
| <p>Push one input token in the execution context</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>exec</tt></i>:</span></td> |
| <td>a regexp execution context or NULL to indicate the end</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>value</tt></i>:</span></td> |
| <td>the first string token input</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>value2</tt></i>:</span></td> |
| <td>the second string token input</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>data</tt></i>:</span></td> |
| <td>data associated to the token to reuse in callbacks</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>1 if the regexp reached a final state, 0 if non-final, and a negative value in case of error.</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegFreeExecCtxt"></a>xmlRegFreeExecCtxt ()</h3> |
| <pre class="programlisting">void xmlRegFreeExecCtxt (<a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> exec)<br> |
| </pre> |
| <p>Free the structures associated to a regular expression evaluation context.</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody><tr> |
| <td><span class="term"><i><tt>exec</tt></i>:</span></td> |
| <td>a regular expression evaluation context</td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegFreeRegexp"></a>xmlRegFreeRegexp ()</h3> |
| <pre class="programlisting">void xmlRegFreeRegexp (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> regexp)<br> |
| </pre> |
| <p>Free a regexp</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody><tr> |
| <td><span class="term"><i><tt>regexp</tt></i>:</span></td> |
| <td>the regexp</td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegNewExecCtxt"></a>xmlRegNewExecCtxt ()</h3> |
| <pre class="programlisting"><a href="libxml2-xmlregexp.html#xmlRegExecCtxtPtr">xmlRegExecCtxtPtr</a> xmlRegNewExecCtxt (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> comp, <br> <a href="libxml2-xmlregexp.html#xmlRegExecCallbacks">xmlRegExecCallbacks</a> callback, <br> void * data)<br> |
| </pre> |
| <p>Build a context used for progressive evaluation of a regexp.</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>comp</tt></i>:</span></td> |
| <td>a precompiled regular expression</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>callback</tt></i>:</span></td> |
| <td>a callback function used for handling progresses in the automata matching phase</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>data</tt></i>:</span></td> |
| <td>the context data associated to the callback in this context</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>the new context</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegexpCompile"></a>xmlRegexpCompile ()</h3> |
| <pre class="programlisting"><a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> xmlRegexpCompile (const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * regexp)<br> |
| </pre> |
| <p>Parses a regular expression conforming to XML Schemas Part 2 Datatype Appendix F and builds an automata suitable for testing strings against that regular expression</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>regexp</tt></i>:</span></td> |
| <td>a regular expression string</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>the compiled expression or NULL in case of error</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegexpExec"></a>xmlRegexpExec ()</h3> |
| <pre class="programlisting">int xmlRegexpExec (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> comp, <br> const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br> |
| </pre> |
| <p>Check if the regular expression generates the value</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>comp</tt></i>:</span></td> |
| <td>the compiled regular expression</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>content</tt></i>:</span></td> |
| <td>the value to check against the regular expression</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>1 if it matches, 0 if not and a negative value in case of error</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegexpIsDeterminist"></a>xmlRegexpIsDeterminist ()</h3> |
| <pre class="programlisting">int xmlRegexpIsDeterminist (<a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> comp)<br> |
| </pre> |
| <p>Check if the regular expression is determinist</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>comp</tt></i>:</span></td> |
| <td>the compiled regular expression</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>Returns</tt></i>:</span></td> |
| <td>1 if it yes, 0 if not and a negative value in case of error</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" lang="en"> |
| <h3> |
| <a name="xmlRegexpPrint"></a>xmlRegexpPrint ()</h3> |
| <pre class="programlisting">void xmlRegexpPrint (FILE * output, <br> <a href="libxml2-xmlregexp.html#xmlRegexpPtr">xmlRegexpPtr</a> regexp)<br> |
| </pre> |
| <p>DEPRECATED: Don't use. No-op since 2.14.0.</p> |
| <div class="variablelist"><table border="0"> |
| <col align="left"> |
| <tbody> |
| <tr> |
| <td><span class="term"><i><tt>output</tt></i>:</span></td> |
| <td>the file for the output debug</td> |
| </tr> |
| <tr> |
| <td><span class="term"><i><tt>regexp</tt></i>:</span></td> |
| <td>the compiled regexp</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| </div> |
| </div> |
| </body> |
| </html> |