Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Hier ist ein kleiner Codeschnipsel, der eine syntaktische Postleitzahlenüberprüfung durchführt. Es handelt sich um einen Programmteil, den Sie wohl wie im Folgenden zu sehen oder auf eine sehr ähnliche Art und Weise realisieren würden:
protected const string USCode =
@"^(\d{5}$)|(\d{5}$\-\d{4}$)";
protected const string CanadianCode =
@"[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d";
public static bool ValidatePostalCode(string str)
{
return (Regex.IsMatch(str, USCode) ||
Regex.IsMatch(str, CanadianCode));
}