using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace I2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strings = new string[]
            {
                "hugo.mueller@mail-server.de",
                "hugo-mueller@web.3",
                "0208/321423",
                "122/23431",
                "4647",
                "D-23452",
                "http://www.subdomain.domain.de/directory/directory/file.html",
                "http//www.subdomain.de/file.html",
                "http://www.domain.de/directory/file.html"
            };
            Console.WriteLine(strings[0]);
            Console.WriteLine("Ist E-Mail-Adresse?: " + Validator.IsEmailAddress(strings[0]));
            Console.WriteLine(strings[1]);
            Console.WriteLine("Ist E-Mail-Adresse?: " + Validator.IsEmailAddress(strings[1]));
            Console.WriteLine(strings[2]);
            Console.WriteLine("Ist Telefonnummer?: " + Validator.IsTelephoneNumber(strings[2]));
            Console.WriteLine(strings[3]);
            Console.WriteLine("Ist Telefonnummer?: " + Validator.IsTelephoneNumber(strings[3]));
            Console.WriteLine(strings[4]);
            Console.WriteLine("Ist PLZ?: " + Validator.IsPlz(strings[4]));
            Console.WriteLine(strings[5]);
            Console.WriteLine("Ist PLZ?: " + Validator.IsPlz(strings[5]));
            Console.WriteLine(strings[6]);
            Console.WriteLine("Ist URL?: " + Validator.IsUrl(strings[6]));
            Console.WriteLine(strings[7]);
            Console.WriteLine("Ist URL?: " + Validator.IsUrl(strings[7]));
            Console.WriteLine(strings[8]);
            Console.WriteLine("Ist URL?: " + Validator.IsUrl(strings[8]));
            string parse = "he fs@w34.de dsd@ mnb@dvn.de @sfdf";
            string[] erg = Validator.ParseForEmailAddresses(parse);
            foreach (string s in erg)
                Console.WriteLine(s);
            Console.ReadLine();
        }
    }

    class Validator
    {
        static public bool IsEmailAddress(string text)
        {
            string pattern = @"^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z]{2,4}$";
            return Regex.IsMatch(text, pattern);
        }

        static public bool IsTelephoneNumber(string text)
        {
            string pattern = @"^0\d{2,4}\/\d{3,7}$";
            return Regex.IsMatch(text, pattern);
        }

        static public bool IsPlz(string text)
        {
            string pattern = @"^(D-)?\d{5}$";
            return Regex.IsMatch(text, pattern);
        }

       static public bool IsUrl(string text)
        {
            string pattern = @"^[a-zA-Z]+:\/\/\w+\.(\w+\.)*\w+\/((\w+\/)?)+\w+\.\w{3,4}";
            return Regex.IsMatch(text, pattern);
        }

       static public string[] ParseForEmailAddresses(string text)
       {
           string pattern = @"[\w\.\-]+@[\w\-\.]+\.[a-zA-Z]{2,4}";
           MatchCollection matches = Regex.Matches(text, pattern);
           string[] erg = new string[matches.Count];
           for (int i = 0; i < matches.Count; i++)
               erg[i] = matches[i].ToString();
           return erg;
       }
    }
}
