Web- und Software Development

ValidateZipCode C#

Written By: Mario Priebe - Jul• 02•08

Prüft auf deutsches Postleitzahlenformat.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*wird benoetigt fuer regularExpression*/
        using System.Text.RegularExpressions;
 
        /*method validateZipCode*/
        public bool validatePLZ(string PLZ)
        {
            string plzPattern = @"^(D-)?\d{5}$";
            Regex re = new Regex(plzPattern);
            Match ma = re.Match(PLZ);
            if (ma.Success)
                return true;
            else
                return false;
        }

Ähnliche Beiträge

You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.