Regular Expression Helper Class

using System;
using System.Text.RegularExpressions;

namespace RickSchott.Util
{
    ///
    /// Summary description for RegExValidators.
    ///
    public class RegExValidators
    {
        public const string regPhoneNumber = @"^(?:([2-9]d{2}) ?|[2-9]d{2}(?:-?| ?))[2-9]d{2}[- ]?d{4}$";
        public const string regEmail = @"^[w-]+(?:.[w-]+)*@(?:[w-]+.)+[a-zA-Z]{2,7}$";
        public const string regZipCode = @"^(?(^00000(|-0000))|(d{5}(|-d{4})))$";
        public RegExValidators()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public static bool isValid(string input, string regConst)
        {
            return Regex.Match(input, regConst).Success;
        }
    }
}
Posted in C#. Tags: , . Leave a Comment »