From 2bae847079852eb808e50a136659e98898616bef Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sat, 23 Jul 2022 22:15:02 +0200 Subject: Fixed a few small issues with cregex.c Reverted cregex_match() to cregex_find(). Renamed cre_* flags. --- examples/regex1.c | 2 +- examples/regex2.c | 2 +- examples/regex_match.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/regex1.c b/examples/regex1.c index 98fc644d..7e8040ac 100644 --- a/examples/regex1.c +++ b/examples/regex1.c @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) if (cstr_equals(input, "q")) break; - if (cregex_match(cstr_str(&input), &float_expr, NULL, 0) == 1) + if (cregex_is_match(cstr_str(&input), &float_expr, 0)) printf("Input is a float\n"); else printf("Invalid input : Not a float\n"); diff --git a/examples/regex2.c b/examples/regex2.c index 23f774ba..307579d4 100644 --- a/examples/regex2.c +++ b/examples/regex2.c @@ -20,7 +20,7 @@ int main() } csview m[20]; printf("input: %s\n", inputs[i]); - if (cregex_match(inputs[i], &re, m, 0) == 1) + if (cregex_find(inputs[i], &re, m, 0) == 1) { c_forrange (j, cregex_captures(&re)) { diff --git a/examples/regex_match.c b/examples/regex_match.c index 821813bb..cb0fdd11 100644 --- a/examples/regex_match.c +++ b/examples/regex_match.c @@ -15,20 +15,20 @@ int main() int res = cregex_compile(&re, "[+-]?([0-9]*\\.)?\\d+([Ee][+-]?\\d+)?", 0); printf("%d\n", res); csview m[5]; - if (cregex_match(s, &re, m, 0) == 1) { + if (cregex_find(s, &re, m, 0) == 1) { printf("Found digits at position %" PRIuMAX "-%" PRIuMAX "\n", m[0].str - s, m[0].str - s + m[0].size); } else { printf("Could not find any digits\n"); } - while (cregex_match(s, &re, m, cre_NEXT) == 1) { + while (cregex_find(s, &re, m, cre_m_next) == 1) { printf("%" c_PRIsv " ; ", c_ARGsv(m[0])); } puts(""); res = cregex_compile(&re, "(.+)\\b(.+)", 0); printf("groups: %d\n", res); - if ((res = cregex_match("hello@wørld", &re, m, 0)) == 1) { + if ((res = cregex_find("hello@wørld", &re, m, 0)) == 1) { c_forrange (i, res) printf("match: [%" c_PRIsv "]\n", c_ARGsv(m[i])); } else -- cgit v1.2.3