diff options
| author | Tyge Løvset <[email protected]> | 2022-01-09 10:17:23 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-01-09 10:17:23 +0100 |
| commit | 8a38affcb58be7eba502d32b78c84b376fe4fe45 (patch) | |
| tree | 874181943ae617e5f3383b0475b99956074bacda /examples | |
| parent | 63562f5135243ac2a2553b4e7360c59e86686d6f (diff) | |
| download | STC-modified-8a38affcb58be7eba502d32b78c84b376fe4fe45.tar.gz STC-modified-8a38affcb58be7eba502d32b78c84b376fe4fe45.zip | |
More on regex.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/regex_match.c | 10 |
1 files changed, 3 insertions, 7 deletions
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("");
}
|
