Fix bug where wrong regexps flags were generated (fixes #426)