Throw IllegalArgumentException if given an invalid search string for
substitution.