Case insensitive and pattern matching

This replaces pull request #1751. This is for issue #1724.
Is `lower()` needed here and with `glob=`? If it is, e.g. for consistency reason, it should be documented and tested.