Case insensitive and pattern matching

For issue #1724
Adding docstrings