matches pattern to matches