Wednesday, February 1, 2012

Ragex(Validation Class In C#)


//Ragex Class

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

namespace Ozzit.Classes
{
    public static class RegexValidation
    {
        #region AlphaSpace
            public static bool isAlphaSpace(string input)
            {
                Regex objAlphaSpacePattern = new Regex(@"^[a-zA-Z-\b' ']*$");
                return objAlphaSpacePattern.IsMatch(input);
            }
        #endregion

        #region ALpha
            public static bool isAlpha(string input)
            {
                Regex objAlphaPattern = new Regex(@"^[a-zA-Z-\b]*$");
                return objAlphaPattern.IsMatch(input);
            }
        #endregion  

        #region AlphaCapital
            public static bool isAlphaCapital(string input)
            {
                Regex objAlphaCapitalPattern = new Regex(@"^[A-Z-\b]*$");
                return objAlphaCapitalPattern.IsMatch(input);
            }
        #endregion

        #region AlphaSmall
            public static bool isAlphaSmall(string input)
            {
                Regex objAlphaSmallPattern = new Regex(@"^[a-z-\b]*$");
                return objAlphaSmallPattern.IsMatch(input);
            }
        #endregion

        #region Number
            public static bool isNumber(string input)
            {
                Regex objNumberPattern = new Regex(@"^[0-9-\b]*$");
                return objNumberPattern.IsMatch(input);
            }
        #endregion

        #region AlphaNumber
            public static bool isAlphaNumber(string input)
            {
                Regex objAlphaNumberPattern = new Regex(@"^[a-zA-Z0-9-\b]*$");
                return objAlphaNumberPattern.IsMatch(input);
            }
        #endregion

        #region UserID
            public static bool isUserId(string input)
            {
                Regex objUserId = new Regex(@"^[a-zA-Z0-9-\b@_.]*$");
                return objUserId.IsMatch(input);
            }
        #endregion

        #region AlphaDot
            public static bool isAlphaDot(string input)
            {
                Regex objAlphaDotPattern = new Regex(@"^[a-z-A-Z-,-.-\b]*$");
                return objAlphaDotPattern.IsMatch(input);
            }
        #endregion
           
    }
}
}

No comments:

Post a Comment