Console.Write("Enter an e-mail address:"); string emailInput = Console.ReadLine(); bool match = Regex.IsMatch(emailInput, emailPattern); if (match) Console.WriteLine("E-mail address is valid."); else Console.WriteLine("Supplied input is not a valid e-mail address.");
string urlPattern = @"^(?<proto>\w+)://[^/]+?(?<port>:\d+)?/"; Console.WriteLine(); Console.Write("Enter a URL for data parsing: "); string url = Console.ReadLine(); Regex urlExpression = new Regex(urlPattern, RegexOptions.Compiled); Match urlMatch = urlExpression.Match(url); Console.WriteLine("The Protocol you entered was " + urlMatch.Groups["proto"].Value); Console.WriteLine("The Port Number you entered was " + urlMatch.Groups["port"].Value);