diff --git a/src/winio.c b/src/winio.c
index a1a933e3ac46c009b30387dbd44203be393e04e5..eda5e5ac49732549c588b0095ef5753f518d8ee3 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2236,10 +2236,12 @@ void do_replace_highlight(int highlight_flag, const char *word)
     if (highlight_flag)
 	wattron(edit, A_REVERSE);
 
+#ifdef HAVE_REGEX_H
     /* This is so we can show zero-length regexes. */
     if (word_len == 0)
 	waddstr(edit, " ");
     else
+#endif
 	waddnstr(edit, word, y - 1);
 
     if (word_len > y)