| libxml2 Reference Manual |
|---|
xmlregexp - regular expressions handling
basic API for libxml regular expressions handling used for XML Schemas and validation.
Author(s): Daniel Veillard
typedef struct _xmlRegExecCtxt xmlRegExecCtxt; typedef xmlRegExecCtxt * xmlRegExecCtxtPtr; typedef struct _xmlRegexp xmlRegexp; typedef xmlRegexp * xmlRegexpPtr; typedef void xmlRegExecCallbacks (xmlRegExecCtxtPtr exec,
const xmlChar * token,
void * transdata,
void * inputdata); int xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,
const xmlChar ** string,
int * nbval,
int * nbneg,
xmlChar ** values,
int * terminal); int xmlRegExecNextValues (xmlRegExecCtxtPtr exec,
int * nbval,
int * nbneg,
xmlChar ** values,
int * terminal); int xmlRegExecPushString (xmlRegExecCtxtPtr exec,
const xmlChar * value,
void * data); int xmlRegExecPushString2 (xmlRegExecCtxtPtr exec,
const xmlChar * value,
const xmlChar * value2,
void * data); void xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec); void xmlRegFreeRegexp (xmlRegexpPtr regexp); xmlRegExecCtxtPtr xmlRegNewExecCtxt (xmlRegexpPtr comp,
xmlRegExecCallbacks callback,
void * data); xmlRegexpPtr xmlRegexpCompile (const xmlChar * regexp); int xmlRegexpExec (xmlRegexpPtr comp,
const xmlChar * content); int xmlRegexpIsDeterminist (xmlRegexpPtr comp); void xmlRegexpPrint (FILE * output,
xmlRegexpPtr regexp);
struct _xmlRegExecCtxt {
The content of this structure is not made public by the API.
} xmlRegExecCtxt;
xmlRegExecCtxt * xmlRegExecCtxtPtr;
A libxml progressive regular expression evaluation context
struct _xmlRegexp {
The content of this structure is not made public by the API.
} xmlRegexp;
xmlRegexp * xmlRegexpPtr;
A libxml regular expression, they can actually be far more complex thank the POSIX regex expressions.
void xmlRegExecCallbacks (xmlRegExecCtxtPtr exec,
const xmlChar * token,
void * transdata,
void * inputdata)
Callback function when doing a transition in the automata
| exec: | the regular expression context |
| token: | the current token string |
| transdata: | transition data |
| inputdata: | input data |
int xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,
const xmlChar ** string,
int * nbval,
int * nbneg,
xmlChar ** values,
int * terminal)
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
| exec: | a regexp execution context generating an error |
| string: | return value for the error string |
| nbval: | pointer to the number of accepted values IN/OUT |
| nbneg: | return number of negative transitions |
| values: | pointer to the array of acceptable values |
| terminal: | return value if this was a terminal state |
| Returns: | 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. |
int xmlRegExecNextValues (xmlRegExecCtxtPtr exec,
int * nbval,
int * nbneg,
xmlChar ** values,
int * terminal)
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
| exec: | a regexp execution context |
| nbval: | pointer to the number of accepted values IN/OUT |
| nbneg: | return number of negative transitions |
| values: | pointer to the array of acceptable values |
| terminal: | return value if this was a terminal state |
| Returns: | 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. |
int xmlRegExecPushString (xmlRegExecCtxtPtr exec,
const xmlChar * value,
void * data)
Push one input token in the execution context
| exec: | a regexp execution context or NULL to indicate the end |
| value: | a string token input |
| data: | data associated to the token to reuse in callbacks |
| Returns: | 1 if the regexp reached a final state, 0 if non-final, and a negative value in case of error. |
int xmlRegExecPushString2 (xmlRegExecCtxtPtr exec,
const xmlChar * value,
const xmlChar * value2,
void * data)
Push one input token in the execution context
| exec: | a regexp execution context or NULL to indicate the end |
| value: | the first string token input |
| value2: | the second string token input |
| data: | data associated to the token to reuse in callbacks |
| Returns: | 1 if the regexp reached a final state, 0 if non-final, and a negative value in case of error. |
void xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec)
Free the structures associated to a regular expression evaluation context.
| exec: | a regular expression evaluation context |
xmlRegExecCtxtPtr xmlRegNewExecCtxt (xmlRegexpPtr comp,
xmlRegExecCallbacks callback,
void * data)
Build a context used for progressive evaluation of a regexp.
| comp: | a precompiled regular expression |
| callback: | a callback function used for handling progresses in the automata matching phase |
| data: | the context data associated to the callback in this context |
| Returns: | the new context |
xmlRegexpPtr xmlRegexpCompile (const xmlChar * regexp)
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
| regexp: | a regular expression string |
| Returns: | the compiled expression or NULL in case of error |
int xmlRegexpExec (xmlRegexpPtr comp,
const xmlChar * content)
Check if the regular expression generates the value
| comp: | the compiled regular expression |
| content: | the value to check against the regular expression |
| Returns: | 1 if it matches, 0 if not and a negative value in case of error |
int xmlRegexpIsDeterminist (xmlRegexpPtr comp)
Check if the regular expression is determinist
| comp: | the compiled regular expression |
| Returns: | 1 if it yes, 0 if not and a negative value in case of error |
void xmlRegexpPrint (FILE * output,
xmlRegexpPtr regexp)
DEPRECATED: Don't use. No-op since 2.14.0.
| output: | the file for the output debug |
| regexp: | the compiled regexp |