Refactor into key-substring-match.