Case insensitive and pattern matching

This replaces pull request #1751. This is for issue #1724.
1) Is self.flags really needed? Why not to pass flags to _get_and_compile_regexp?

2) Is re.IGNORECASE needed? Aren't both pattern and matched string normalized anyway? If it's not needed, there's no need to pass flags at all, re.compile can just use re.DOTALL.