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
use extended regular expressions if using std::regex

some compilers (e.g., GCC < 4.9) seem to need it...

thanks to [at]bska for digging this up!