Code-Validator: verify email

ylbtech-Code-Validator: verify email

 

1. Back to top
1、
the using the System;
 the using the System.Text.RegularExpressions; 

namespace Sp.Common 
{ 
    public  class ValidatorHelper 
    { 
        ///  <Summary>   
        /// verification email  
         /// [@ character before may contain letters, numbers, underscores, and; @ Characters can contain letters, numbers, underscores, and dots; @ character contains at least one dot and the dot cannot be the last character; the last dot can only be letters or numbers]  
         ///  </ summary>   
        / //  <param name = "input"> string to be verified </ param>   
        ///  <returns> whether it matches </ returns>   
        public  static  bool IsEmail ( string input) 
        { 
            //// The mailbox name starts with a number or letter; the mailbox name can be composed of letters, numbers, dots, minus signs, and underscores; the mailbox name (the character before @) is 3 to 18 characters long; Or the end of the underscore; two or more consecutive dots and minus signs cannot appear.  
            // string pattern = @ "^ [a-zA-Z0-9] ((? <! (\. \. |-)) [a-zA-Z0-9 \ ._-]) {1,16 } [a-zA-Z0-9] @ ([0-9a-zA-Z] [0-9a-zA-Z-] {0,62} \.) + ([0-9a-zA-Z] [0-9a-zA-Z-] {0,62}) \.? | ((25 [0-5] | 2 [0-4] \ d | [01]? \ D \ d?) \. ) {3} (25 [0-5] | 2 [0-4] \ d | [01]? \ D \ d?) $ ";   
            String pattern = @" ^ ([\ w-\.] +) @ ([\ W - \.] +) (\ [A-zA-Z0-9] +.) $ " ;
             return IsMatch (INPUT, pattern); 
        } 

        #region matching  
         ///  <Summary>   
        /// Verify that the string matches the rules described by the regular expression  
         ///  </ summary>   
        ///  <param name = "inputStr"></ param>   
        ///  <param name = "patternStr"> Regular expression string </ param>   
        ///  <returns> Does it match </ returns>   
        public  static  bool IsMatch ( string inputStr, string patternStr) 
        { 
            return IsMatch (inputStr, patternStr, false , false ); 
        } 

        ///  <summary>   
        /// Verify that the string matches the rules described by the regular expression  
         ///  </ summary>   
        ///  <param name = "inputStr"> wait Verified string </ param>   
        ///  <param name = "patternStr">Regular expression string </ param>  
        ///  <param name = "ifIgnoreCase"> Is it case-insensitive when matching </ param>   
        ///  <returns> is it matching </ returns>   
        public  static  bool IsMatch ( string inputStr, string patternStr, bool ifIgnoreCase) 
        { 
            return IsMatch (inputStr, patternStr, ifIgnoreCase, false ); 
        } 

        ///  <summary>   
        /// Verify that the string matches the rules described by the regular expression  
         ///  </ summary>   
        ///  <param name = "inputStr"> String to be verified </ param>   
        ///  <param name = "patternStr"Regular expression string</ param>   
        ///  <param name = "ifValidateWhiteSpace"> Whether to verify the blank string </ param>   
        ///  <returns> Does it match </ returns>   
        public  static  bool IsMatch1 ( string inputStr, string patternStr, bool ifValidateWhiteSpace) 
        { 
            return IsMatch (inputStr, patternStr, false , ifValidateWhiteSpace); 
        } 

        ///  <summary>   
        /// Verify that the string matches the rules described by the regular expression  
         ///  </ summary>   
        ///  <param name = "inputStr "> String to be verified </ param>  
        /// <param name = "patternStr"> Regular expression string </ param>   
        ///  <param name = "ifIgnoreCase"> Is it case-insensitive when matching </ param>   
        ///  <param name = "ifValidateWhiteSpace"> verify empty string </ param>   
        ///  <Returns> matches </ Returns>   
        public  static  BOOL IsMatch ( string inputstr, string patternStr, BOOL ifIgnoreCase, BOOL ifValidateWhiteSpace) 
        { 
            iF (! && ifValidateWhiteSpace string .
                IsNullOrEmpty(inputStr))
                return false;//If blank string verification is not required and the incoming string to be verified is a blank string at this time, it does not match   
            Regex regex = null ;
             if (ifIgnoreCase) 
                regex = new Regex (patternStr, RegexOptions.IgnoreCase); // Specify not Case-sensitive matching   
            else 
                regex = new Regex (patternStr);
             return regex.IsMatch (inputStr); 
        } 
        #endregion 
    } 
}
2、
2. Back to top
 
3. Back to top
 
4. Back to top
 
5. Back to top
 
 
6. Back to top
 
warn Author: ylbtech
Source: http://ylbtech.cnblogs.com/
This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page, otherwise Reserves the right to pursue legal responsibility.

Guess you like

Origin www.cnblogs.com/storebook/p/12685717.html