summaryrefslogtreecommitdiff
path: root/regex.h
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-22 14:04:24 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-22 14:04:24 +0800
commit4eb551a6fe7f5a69cef0311fe1c4fdf9fe765759 (patch)
treedaeaafe434cec97ce9292dd822aa5102aab435c7 /regex.h
parent3d51ee82115b8e6e619ba817ba8d48672c413845 (diff)
Revert "Merge regex.h, as it's only called 1 time"
This reverts commit 3d51ee82115b8e6e619ba817ba8d48672c413845.
Diffstat (limited to 'regex.h')
-rw-r--r--regex.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/regex.h b/regex.h
new file mode 100644
index 0000000..ebd51ac
--- /dev/null
+++ b/regex.h
@@ -0,0 +1,17 @@
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
+
+static inline bool regex_match(const char *shop)
+{
+ pcre2_code *re = pcre2_compile((PCRE2_SPTR)
+ "^[a-zA-Z0-9][a-zA-Z0-9\\-]*\\.myshopify\\.com",
+ PCRE2_ZERO_TERMINATED, 0, &(int){ 0 },
+ &(PCRE2_SIZE){ 0 }, NULL);
+ pcre2_match_data *match_data
+ = pcre2_match_data_create_from_pattern(re, NULL);
+ int rc = pcre2_match(re, (PCRE2_SPTR)shop, strlen(shop), 0, 0,
+ match_data, NULL);
+ pcre2_match_data_free(match_data);
+ pcre2_code_free(re);
+ return rc >= 0;
+}