aboutsummaryrefslogtreecommitdiff
path: root/src/regex.c
blob: 866c6e802c1fee44cac0a178e41c1e8f29087c27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "regex.h"
#include <regex.h>
#include <stddef.h>

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