34static int test_replace(
const char* pattern,
const char* subject,
const char* repl,
const char* want) {
37 int ok = (out && out->
data && strcmp(out->
data, want) == 0);
39 n_log(
LOG_ERR,
"npcre_replace(/%s/, '%s', '%s') -> '%s', expected '%s'",
40 pattern, subject, repl, (out && out->
data) ? out->
data :
"(null)", want);
48int main(
int argc,
char** argv) {
67 n_log(
LOG_INFO,
"ex_pcre: pass \"regexp\" \"string\" to also run the match demo");
static int test_replace(const char *pattern, const char *subject, const char *repl, const char *want)
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
#define LOG_STDERR
internal, default LOG_TYPE
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
#define LOG_INFO
informational
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
A box including a string and his lenght.
PCRE2_UCHAR8 ** match_list
populated match list (NULL-terminated) after npcre_match_capture() Allocated by PCRE2 via pcre2_subst...
int captured
flag for match_list cleaning
N_PCRE * npcre_new(char *str, int flags)
From pcre doc, the flag bits are: PCRE_ANCHORED Force pattern anchoring PCRE_AUTO_CALLOUT Compile aut...
int npcre_match_capture(char *str, N_PCRE *pcre)
Return TRUE if str matches regexp, and make captures.
int npcre_clean_match(N_PCRE *pcre)
clean the match list of the last capture, if any
N_STR * npcre_replace(N_PCRE *pcre, const char *subject, size_t subject_len, const char *replacement)
thread-safe regex substitute: replace every match in subject (binary-safe, subject_len bytes) using a...
int npcre_delete(N_PCRE **pcre)
Free a N_PCRE pointer.
PCRE helpers for regex matching.