summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/regularexpressions/regex_replace.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-08-14 16:46:24 +0200
committerTyge Løvset <[email protected]>2023-08-14 16:46:24 +0200
commit78d8668e6d527070568a405408ed906e51055bf4 (patch)
tree60f963a36826acce264c7ecd0af3eb80502a4335 /misc/examples/regularexpressions/regex_replace.c
parent2b6b4785c5c26bc47d800c1a7c7a48784df2d57b (diff)
downloadSTC-modified-78d8668e6d527070568a405408ed906e51055bf4.tar.gz
STC-modified-78d8668e6d527070568a405408ed906e51055bf4.zip
Reverted csubstr => csview. Sorry about that!
Added crawstr to become the null-terminated string view.
Diffstat (limited to 'misc/examples/regularexpressions/regex_replace.c')
-rw-r--r--misc/examples/regularexpressions/regex_replace.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/misc/examples/regularexpressions/regex_replace.c b/misc/examples/regularexpressions/regex_replace.c
index f5fd8691..f1ea2711 100644
--- a/misc/examples/regularexpressions/regex_replace.c
+++ b/misc/examples/regularexpressions/regex_replace.c
@@ -1,8 +1,8 @@
#define i_import
#include <stc/cregex.h>
-#include <stc/csubstr.h>
+#include <stc/csview.h>
-bool add_10_years(int i, csubstr match, cstr* out) {
+bool add_10_years(int i, csview match, cstr* out) {
if (i == 1) { // group 1 matches year
int year;
sscanf(match.str, "%4d", &year); // scan 4 chars only
@@ -47,7 +47,7 @@ int main(void)
printf("euros: %s\n", cstr_str(&str));
/* Strip out everything but the matches */
- cstr_take(&str, cregex_replace_ss(&re, csubstr_from(input), "$3.$2.$1;", 0, NULL, CREG_STRIP));
+ cstr_take(&str, cregex_replace_sv(&re, csview_from(input), "$3.$2.$1;", 0, NULL, CREG_STRIP));
printf("strip: %s\n", cstr_str(&str));
/* Wrap all words in ${} */