diff options
Diffstat (limited to 'misc/examples/splitstr.c')
| -rw-r--r-- | misc/examples/splitstr.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/misc/examples/splitstr.c b/misc/examples/splitstr.c new file mode 100644 index 00000000..a3c12a3a --- /dev/null +++ b/misc/examples/splitstr.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#define i_extern // cstr + utf8 functions +#include <stc/cregex.h> +#include <stc/csview.h> + +int main() +{ + puts("Split with c_fortoken (csview):"); + + c_fortoken (i, "Hello World C99!", " ") + printf("'%.*s'\n", c_ARGSV(i.token)); + + + puts("\nSplit with c_formatch (regex):"); + + c_with (cregex re = cregex_from("[^ ]+", CREG_DEFAULT), cregex_drop(&re)) + c_formatch (i, &re, " Hello World C99! ") + printf("'%.*s'\n", c_ARGSV(i.match[0])); +} |
