Fix infinite loop when regexp-matching an empty string
See Debian bug https://bugs.debian.org/358389