mirror of
https://github.com/Jous99/F4MP.git
synced 2026-01-12 08:40:53 +01:00
31 lines
761 B
C
31 lines
761 B
C
#define ZPL_IMPLEMENTATION
|
|
#define ZPL_NANO
|
|
#define ZPL_ENABLE_REGEX
|
|
#include <zpl.h>
|
|
|
|
int main(void) {
|
|
|
|
zpl_re re={0};
|
|
|
|
char const* pat = "(//<<([\\w._]+)>>)";
|
|
|
|
u32 err = zpl_re_compile(&re, zpl_heap(), pat, zpl_strlen(pat));
|
|
if (err) {
|
|
zpl_printf("Regex pattern is invalid! Error code: %d\n", err);
|
|
}
|
|
|
|
zpl_printf("Regex pattern was compiled!\n");
|
|
|
|
char const* str = "//<<buffer.c>> aaa //<<hello.c>>\n aa//<<aaa.c>>//<<test.c>>";
|
|
|
|
zpl_array_make(zpl_re_capture, captures, zpl_heap());
|
|
|
|
zpl_re_match_all(&re, str, zpl_strlen(str), 2, &captures);
|
|
|
|
for (isize i=0; i < zpl_array_count(captures); i++)
|
|
{
|
|
zpl_printf("Group %ld: %.*s\n", i, (i32)captures[i].len, captures[i].str);
|
|
}
|
|
|
|
return 0;
|
|
}
|