Case insensitive and pattern matching

This replaces pull request #1751. This is for issue #1724.
Missing `whitespace_insensitive` here and in get_match_count. Would be good to add examples to both too.