aboutsummaryrefslogtreecommitdiff
path: root/src/regex.c
diff options
context:
space:
mode:
authorLibravatar Martin Michalec <martin@michalec.dev>2026-11-08 05:23:31 +0000
committerLibravatar Martin Michalec <martin@michalec.dev>2026-11-08 05:24:55 +0000
commit3f36aca66e1ac6c872300059e8db691a473614d4 (patch)
tree48c65f463c487d281c7c4091c7ba01dd4a2ff8f1 /src/regex.c
downloadlab-02-3f36aca66e1ac6c872300059e8db691a473614d4.tar.gz
publishHEADmaster
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c18
1 files changed, 18 insertions, 0 deletions
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 @@
1#include "regex.h"
2#include <regex.h>
3#include <stddef.h>
4
5static regex_t compiled;
6const 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]\\)*\\)\\?\\)$";
7
8static void __attribute__((constructor))
9init (void)
10{
11 regcomp (&compiled, regex_pattern, REG_NOSUB);
12}
13
14bool
15regex_match (const char *string)
16{
17 return !regexec (&compiled, string, 0, NULL, 0);
18}