summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/strings/splitstr.c
diff options
context:
space:
mode:
author_Tradam <[email protected]>2023-09-08 01:29:47 +0000
committerGitHub <[email protected]>2023-09-08 01:29:47 +0000
commit3c76c7f3d5db3f9586a90d03f8fbb02d79de9acd (patch)
treeafbe4b540967223911f7c5de36559b82154f02f3 /misc/examples/strings/splitstr.c
parent0841165881871ee01b782129be681209aeed2423 (diff)
parent1a72205fe05c2375cfd380dd8381a8460d9ed8d1 (diff)
downloadSTC-modified-modified.tar.gz
STC-modified-modified.zip
Merge branch 'stclib:master' into modifiedHEADmodified
Diffstat (limited to 'misc/examples/strings/splitstr.c')
-rw-r--r--misc/examples/strings/splitstr.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/misc/examples/strings/splitstr.c b/misc/examples/strings/splitstr.c
new file mode 100644
index 00000000..ef7ed174
--- /dev/null
+++ b/misc/examples/strings/splitstr.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#define i_import // cstr + utf8 functions
+#include <stc/cregex.h>
+#define i_implement
+#include <stc/csview.h>
+
+int main(void)
+{
+ puts("Split with c_fortoken (csview):");
+
+ c_fortoken (i, "Hello World C99!", " ")
+ printf("'%.*s'\n", c_SV(i.token));
+
+ puts("\nSplit with c_formatch (regex):");
+
+ cregex re = cregex_from("[^ ]+");
+ c_formatch (i, &re, " Hello World C99! ")
+ printf("'%.*s'\n", c_SV(i.match[0]));
+
+ cregex_drop(&re);
+}