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;
        }
    }
}
Advertisements
Posted in C#. Tags: , . Leave a Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: