Mega Code Archive

 
Categories / C# / Development Class
 

Validate address

using System; using System.Text.RegularExpressions; class RegexSubstitution {    public static void Main()    {       string text = "124 street";       if ( !Regex.Match( text, @"^[0-9]+\s+([a-zA-Z]+|[a-zA-Z]+\s[a-zA-Z]+)$" ).Success ) {          Console.WriteLine( "Invalid address");       }     } }