pmatch, pmatchx - test if a string matches a regular expression |
#include <pstring.h> #define pmatch(p,str,re) pmatchx ((p), (str), (re), REG_EXTENDED, 0, 0) vector pmatchx (pool, const char *str, const char *re, int cflags, int eflags, int flags); |
pmatch is used as a quick way to test if a string str matches a POSIX regular expression re. The function internally caches compiled regular expressions for speed. The function returns a vector of char *, containing the list of substrings which match. If the regular expression does not match, then NULL is returned. |
pmatchx is the same as pmatch except that it allows greater control with flags. cflags and eflags are passed directly to regcomp(3) and regexec(3) respectively. flags may contain: |
PMATCH_NO_CACHE: Compile the regular expression regardless of whether the re is stored in the cache, and do not store the compiled regular expression back into the cache. This flag is useful to save memory if you know that the particular re will only be used very infrequently, and hence storing it in the cache would just be a waste of space. |
Note that the state of cflags is not stored in the cache. In rare circumstances this could cause problems. |
Richard Jones <rich@annexia.org> |
GNU LGPL (see http://www.gnu.org/) |
c2lib-1.2.13 |