Case insensitive and pattern matching

This replaces pull request #1751. This is for issue #1724.
Yeah, I meant that `_yield_regexp` could be renamed to `_glob_pattern_to_regexp` to make the code a bit more explicit about the fact that given pattern can be regexp or glob.