summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-07-21 16:33:39 +0200
committerTyge Løvset <[email protected]>2022-07-21 16:35:11 +0200
commitf1bc406edb6faef3420de7f77a6f1246065861d9 (patch)
tree2ae4340cbd61bab19044964b66bc4111f4f04edc /examples
parent782fa268940611df14bce7823b4aaf6fca671b49 (diff)
downloadSTC-modified-f1bc406edb6faef3420de7f77a6f1246065861d9.tar.gz
STC-modified-f1bc406edb6faef3420de7f77a6f1246065861d9.zip
cregex API change: Added cregex_match_ex() and cregex_match() with string pattern input instead of a cregex*, similar to cregex_replace*().
Diffstat (limited to 'examples')
-rw-r--r--examples/regex1.c3
-rw-r--r--examples/regex2.c2
-rw-r--r--examples/regex_match.c6
3 files changed, 6 insertions, 5 deletions
diff --git a/examples/regex1.c b/examples/regex1.c
index 09e4299d..d5c14509 100644
--- a/examples/regex1.c
+++ b/examples/regex1.c
@@ -1,3 +1,4 @@
+#define i_implement
#include <stc/cstr.h>
#include <stc/cregex.h>
@@ -21,7 +22,7 @@ int main(int argc, char* argv[])
if (cstr_equals(input, "q"))
break;
- if (cregex_match(&float_expr, cstr_str(&input), 0, NULL, 0) > 0)
+ if (cregex_match_re(cstr_str(&input), &float_expr, 0, NULL, 0) > 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 1f3163f7..0d10205a 100644
--- a/examples/regex2.c
+++ b/examples/regex2.c
@@ -20,7 +20,7 @@ int main()
}
cregmatch m[20];
printf("input: %s\n", inputs[i]);
- if (cregex_match(&re, inputs[i], 20, m, 0) > 0)
+ if (cregex_match_re(inputs[i], &re, 20, m, 0) > 0)
{
c_forrange (j, cregex_captures(&re))
{
diff --git a/examples/regex_match.c b/examples/regex_match.c
index 5680b55e..5f1075ff 100644
--- a/examples/regex_match.c
+++ b/examples/regex_match.c
@@ -14,20 +14,20 @@ int main()
int res = cregex_compile(&re, "[+-]?([0-9]*\\.)?\\d+([Ee][+-]?\\d+)?", 0);
printf("%d\n", res);
csview m[10];
- if (cregex_match(&re, s, 10, m, 0) > 0) {
+ if (cregex_match_re(s, &re, 10, m, 0) > 0) {
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(&re, s, 10, m, cregex_NEXT) > 0) {
+ while (cregex_match_re(s, &re, 10, m, cre_NEXT) > 0) {
printf("%" c_PRIsv " ; ", c_ARGsv(m[0]));
}
puts("");
res = cregex_compile(&re, "(.+)\\b(.+)", 0);
printf("groups: %d\n", res);
- if ((res = cregex_match(&re, "hello@wørld", 10, m, 0)) > 0) {
+ if ((res = cregex_match_re("hello@wørld", &re, 10, m, 0)) > 0) {
c_forrange (i, res)
printf("match: [%" c_PRIsv "]\n", c_ARGsv(m[i]));
} else