From 8a38affcb58be7eba502d32b78c84b376fe4fe45 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sun, 9 Jan 2022 10:17:23 +0100 Subject: More on regex. --- examples/regex_match.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/regex_match.c b/examples/regex_match.c index 01cbb772..5e9775b4 100644 --- a/examples/regex_match.c +++ b/examples/regex_match.c @@ -23,13 +23,9 @@ int main() printf("Could not find any digits\n"); } - c_auto (cregex_result, matches) { - matches = cregex_find_all(re, s); - csview sv = csview_from(s); - c_foreach (i, cregex_result, matches) { - csview rs = csview_slice(sv, i.ref->start, i.ref->end); - printf(c_PRIsv " | ", c_ARGsv(rs)); - } + csview sv = {s, 0}; + while (cregex_find_next_v(re, s, &sv)) { + printf(c_PRIsv " | ", c_ARGsv(sv)); } puts(""); } -- cgit v1.2.3