F4MP/f4mp_originalcode/thirdparty/zpl/code/apps/examples/regex.c
Jous99 37b16f1547 code upload
codigo original de f4mp y tilted para referencias
2026-01-06 18:45:00 +01:00

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;
}