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