psubst

NAME
SYNOPSIS
DESCRIPTION
AUTHOR
LICENSE
VERSION

NAME

psubst, psubstx - substitute string matching regular expression

SYNOPSIS

#include <pstring.h>

#define psubst(p,str,pat,sub) psubstx ((p), (str), (pat), (sub), REG_EXTENDED, 0, 0)
const char *psubstx (pool, const char *str, const char *pat, const char *sub, int cflags, int eflags, int flags);

DESCRIPTION

psubst is used as a quick way to substitute strings which match a regular expression with other strings. It is the equivalent of the s/// operator in Perl. The function internally caches compiled regular expressions for speed. The function returns a new string which is formed from str by substituting string sub for the first regular expression which matches pat.
psubstx is the same as psubst except that it allows greater control with flags. cflags and eflags are passed directly to regcomp(3) and regexec(3) respectively. flags may contain:
PSUBST_GLOBAL: Match and replace every instance of pat in the string, not just the first.
PSUBST_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.

AUTHOR

Richard Jones <rich@annexia.org>

LICENSE

GNU LGPL (see http://www.gnu.org/)

VERSION

c2lib-1.2.13