how to match and search pattern