O'Reilly logo

Microsoft® Windows® Workflow Foundation Step by Step by Kenn Scribner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building Your First Workflow Program

Here is a small code snippet that performs postal code validation, and it’s one you’ve no doubt written before or probably very much like one you would write if asked to do so:

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));
}

Nothing special here—"Test the input string against a properly formatted US ZIP code or Canadian postal code and return false if improperly formatted for either postal system." It’s a nice chunk of procedural code, and in fact you could drop it into your ASP.NET validation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required