Mega Code Archive

 
Categories / C# / Development Class
 

Validate ZIP code

using System; using System.Text.RegularExpressions; class RegexSubstitution {    public static void Main()    {       string text = "124";       if ( !Regex.Match( text, @"^\d{5}$" ).Success )       {          Console.WriteLine( "Invalid zip code");       }       } }