diff options
| author | Tyge Løvset <[email protected]> | 2023-07-24 08:48:41 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-24 08:48:41 +0200 |
| commit | 374b3c27831cd4e09461867ed231669777b96951 (patch) | |
| tree | 88011006f6d536cdb1ad1eca8073392ca80687cc /misc/examples/strings/splitstr.c | |
| parent | 177418232a2d8a8b0df1667d3e4bd15dc37db59f (diff) | |
| parent | 650b053f443f9132dadb6d1ca924c0b36849739f (diff) | |
| download | STC-modified-374b3c27831cd4e09461867ed231669777b96951.tar.gz STC-modified-374b3c27831cd4e09461867ed231669777b96951.zip | |
Merge pull request #65 from stclib/dev43
Dev43
Diffstat (limited to 'misc/examples/strings/splitstr.c')
| -rw-r--r-- | misc/examples/strings/splitstr.c | 21 |
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); +} |
