Revert "Use match() instead of search() for pattern matching"

This reverts commit b4476c238f38d09de918782e6708d0d4d1b57c7f.
Fixed hostname matching with pattern having '~' at the beginning