summaryrefslogtreecommitdiffhomepage
path: root/examples/replace.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-07-27 15:22:38 +0200
committerTyge Løvset <[email protected]>2022-07-27 15:22:38 +0200
commitc37abf4f78b97244e92cba6c352501a4d22110cf (patch)
tree12c49ad74db06641bd7764ea64f5cb56e9fa3f26 /examples/replace.c
parent2bae847079852eb808e50a136659e98898616bef (diff)
downloadSTC-modified-c37abf4f78b97244e92cba6c352501a4d22110cf.tar.gz
STC-modified-c37abf4f78b97244e92cba6c352501a4d22110cf.zip
VERSION 3.8 BETA: Some changes in cstr / csview APIs: replace* / find*, *_u8(). . See README.md
Diffstat (limited to 'examples/replace.c')
-rw-r--r--examples/replace.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/replace.c b/examples/replace.c
index 2926977c..13b6eaaf 100644
--- a/examples/replace.c
+++ b/examples/replace.c
@@ -8,23 +8,27 @@ int main ()
// replace signatures used in the same order as described above:
- // Ustring positions: 0123456789*123456789*12345
- cstr s = cstr_from(base); // "this is a test string."
+ // Ustring positions: 0123456789*123456789*12345
+ cstr s = cstr_from(base); // "this is a test string."
cstr m = cstr_clone(s);
c_autodefer (cstr_drop(&s), cstr_drop(&m)) {
cstr_append(&m, cstr_str(&m));
cstr_append(&m, cstr_str(&m));
printf("%s\n", cstr_str(&m));
- cstr_replace_at(&s, 9, 5, s2); // "this is an example string." (1)
+ cstr_replace_at(&s, 9, 5, s2); // "this is an example string." (1)
printf("(1) %s\n", cstr_str(&s));
- cstr_replace_with_n(&s, 19, 6, s3+7, 6); // "this is an example phrase." (2)
+
+ cstr_replace_at_sv(&s, 19, 6, c_sv(s3+7, 6)); // "this is an example phrase." (2)
printf("(2) %s\n", cstr_str(&s));
- cstr_replace_at(&s, 8, 10, "just a"); // "this is just a phrase." (3)
+
+ cstr_replace_at(&s, 8, 10, "just a"); // "this is just a phrase." (3)
printf("(3) %s\n", cstr_str(&s));
- cstr_replace_with_n(&s, 8, 6,"a shorty", 7); // "this is a short phrase." (4)
+
+ cstr_replace_at_sv(&s, 8, 6, c_sv("a shorty", 7)); // "this is a short phrase." (4)
printf("(4) %s\n", cstr_str(&s));
- cstr_replace_at(&s, 22, 1, "!!!"); // "this is a short phrase!!!" (5)
+
+ cstr_replace_at(&s, 22, 1, "!!!"); // "this is a short phrase!!!" (5)
printf("(5) %s\n", cstr_str(&s));
}
}