About regular expressions to customize check

It contains several rules:

1. Format "BIL1100", the rules: the first three letters, the last four numbers.

var validateNumber = (rule, value, the callback) => { 
        const Age = / ^ [A-Za-Z] {}. 3 [0-9]. 4} {$ / ;
         IF (! {age.test (value)) 
          the callback ( new new Error ( 'format is incorrect, for example: "BIL1100"' )); 
        } the else { 
          the callback (); 
        } 
      };
Rule: first three letters, is the last four numbers

2. verification code format "ss11", rule: four.

var validateCode = (rule, value, the callback) => { 
        const Age = / ^ [0-9a-zA-the Z] {} $. 4 / ;
         IF (! {age.test (value)) 
          the callback ( new new Error ( ' format is not correct, for example: "SS11" ' )); 
        } the else { 
          the callback (); 
        } 
      };
Rules: Four

3. Password rules: 6 to 16 characters, case sensitive.

var validatePass1 = (rule, value, the callback) => { 
       const Age = / ^ [0-9a-zA-the Z] {6,16} $ / ;
         IF (! {age.test (value)) 
          the callback ( new new Error ( 'format is not correct, the rule: 6 to 16 characters, case sensitive.' )); 
        } the else { 
          the callback (); 
        } 
      };
Rule: 6 to 16 characters, case sensitive

4. A description of the problem,

var validateDescribe = (rule, value, the callback) => { 
       Age const = / ^ [\ u4e00- \ u9fa5a-zA-Z0-9] 20 is {,} $ / ;
         IF (! {age.test (value)) 
          the callback ( new new Error ( 'rule: no less than 20 characters' )); 
        } the else { 
          the callback (); 
        } 
      };
Rules: no less than 20 characters

5. Digital

var validateNodeid = (rule, value, the callback) => {
         IF (! Number.isInteger (value)) { 
          the callback ( new new Error ( 'Please input digital value' )); 
        } the else { 
          the callback (); 
        } 
      };
digital

Follow-up will then summarize.

 

Guess you like

Origin www.cnblogs.com/5201314m/p/11354268.html
Recommended