summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-01-07 14:33:29 +0100
committerTyge Løvset <[email protected]>2022-01-07 14:33:29 +0100
commitbcd76fdeb1b7b5ac01ac9a204db74b537361c8b0 (patch)
treeaa294be93eeee868b6c27189f2238378a5e0eada /examples
parent8d5a9ea8b743253bd33b6ecca8e7e4e650aa6f07 (diff)
downloadSTC-modified-bcd76fdeb1b7b5ac01ac9a204db74b537361c8b0.tar.gz
STC-modified-bcd76fdeb1b7b5ac01ac9a204db74b537361c8b0.zip
Some renaming in cregex API. Added match function. Made utf8 operations branchless.
Diffstat (limited to 'examples')
-rw-r--r--examples/regex_match.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/regex_match.c b/examples/regex_match.c
index dad28f84..20d331e2 100644
--- a/examples/regex_match.c
+++ b/examples/regex_match.c
@@ -15,22 +15,24 @@ int main()
c_auto (cregex, re)
{
- re = cregex_compile("[+-]?([0-9]*\\.)?[0-9]+([Ee][-+]?[0-9]+)?");
- cregex_match_t m;
- if (cregex_match(re, s, &m)) {
+ re = cregex_new("[+-]?([0-9]*\\.)?[0-9]+([Ee][-+]?[0-9]+)?");
+ cregex_match m;
+ if (cregex_find(re, s, &m)) {
printf("Found digits at position %u-%u\n", m.match_begin, m.match_end);
} else {
printf("Could not find any digits\n");
}
- c_auto (cregex_res, matches) {
- matches = cregex_match_all(re, s);
+ c_auto (cregex_result, matches) {
+ matches = cregex_find_all(re, s);
csview sv = csview_from(s);
- c_foreach (i, cregex_res, matches) {
+ c_foreach (i, cregex_result, matches) {
csview r = csview_slice(sv, i.ref->match_begin, i.ref->match_end);
printf(c_svfmt " / ", c_svarg(r));
}
}
+
+
puts("");
}
} \ No newline at end of file