From 3f36aca66e1ac6c872300059e8db691a473614d4 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Sun, 8 Nov 2026 08:23:31 +0300 Subject: publish --- src/regex.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/regex.c (limited to 'src/regex.c') diff --git a/src/regex.c b/src/regex.c new file mode 100644 index 0000000..866c6e8 --- /dev/null +++ b/src/regex.c @@ -0,0 +1,18 @@ +#include "regex.h" +#include +#include + +static regex_t compiled; +const char *regex_pattern = "^\\(https\\?://\\)\\?docs\\.\\(new/*\\|google\\.com/document/d/[-0-9A-Z_a-z]\\+\\(/\\(edit\\|view\\|preview\\|copy\\|mobilebasic\\|template/preview\\)\\?\\)\\?\\(?\\([^%]\\|%[0-9A-Fa-f][0-9A-Fa-f]\\)*\\)\\?\\)$"; + +static void __attribute__((constructor)) +init (void) +{ + regcomp (&compiled, regex_pattern, REG_NOSUB); +} + +bool +regex_match (const char *string) +{ + return !regexec (&compiled, string, 0, NULL, 0); +} -- cgit v1.3.1