Apply fix for 5.17.6 and later regexps

Thanks to Ilmari for the patch, sorry for the delay in release.