<commit_before>diff --git a/meson.build b/meson.build
index 5570a8a1f39..3dc876413d0 100644
--- a/meson.build
+++ b/meson.build
@@ -1613,9 +1613,12 @@ endif
 dep_m = cc.find_library('m', required : false)
 
 if host_machine.system() == 'windows'
-  dep_regex = meson.get_compiler('c').find_library('regex', required : false)
+  dep_regex = declare_dependency(dependencies : [dependency('regex', required : false), dependency('iconv', required : false)])
   if not dep_regex.found()
-    dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
+    dep_regex = meson.get_compiler('c').find_library('regex', required : false)
+    if not dep_regex.found()
+      dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
+    endif
   endif
 else
   dep_regex = null_dep<commit_msg>MSYS2 regex link: Avoid warning<commit_after>diff --git a/meson.build b/meson.build
index 5570a8a1f39..3dc876413d0 100644
--- a/meson.build
+++ b/meson.build
@@ -1613,9 +1613,12 @@ endif
 dep_m = cc.find_library('m', required : false)
 
 if host_machine.system() == 'windows'
-  dep_regex = meson.get_compiler('c').find_library('regex', required : false)
+  dep_regex = declare_dependency(dependencies : [dependency('regex', required : false)], link_args : ['-liconv'])
   if not dep_regex.found()
-    dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
+    dep_regex = meson.get_compiler('c').find_library('regex', required : false)
+    if not dep_regex.found()
+      dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
+    endif
   endif
 else
   dep_regex = null_dep
{'fraction_non_alphanumeric': 0.1534090909090909, 'fraction_numerical': 0.0422979797979798, 'mean_word_length': 4.6007067137809186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1866315', 'n_tokens_mistral': 610, 'n_tokens_neox': 547, 'n_words': 106}