fix some "#if without expression" errors

That was caused because the command line flag to define HAVE_REGEX
should only be added if HAVE_REGEX is set to true...
Changed from if to ifdef, to clarify the actual functionality
Merge pull request #260 from flikka/if-to-ifdef

If to ifdef