Regular check - daily general supplement

scenes to be used:

1. Form check:

2. Custom check:

3. Data Filter:

 

First, form validation:

{ pattern: /xxxx/, message: 'xxxx', trigger: 'blur' }
{ validator: validatorFun,required: true, type:'array' }
    validateFun = const (rule, value, the callback) => {
       IF (value) { 
        const pattern = / ^ [\ u4E00- \ _ u9FA5a-zA-Z0-9] + $ /
         IF (! value.match (pattern)) { 
          the callback ( new new Error ( 'only in English, numbers, underscores' )) 
        } the else  IF ( the this .formInfo.tableWideName.indexOf (value)! == -1 ) { 
          the callback ( new new Error ( 'the name already exists' ) ) 
        } the else { 
          the callback () 
        } 
      } the else { 
        the callback ( new newError ( 'Enter characterized in width table' )) 
      } 
    }

1 only in English, numbers, underscores (if allowed to be null, put into + *)

/ ^ [\ U4E00- \ u9FA5a-zA-Z0-9 _] + $ /
Split: / [\ u4e00- \ u9fa5] / + / ^ \ w + $ /
Etc.效: [A-ZA-Z0-9_] =  \ W
 
2. allow only numbers and periods with
/^\d+\.\d+\.\d+$/

 

 
 
Second, custom calibration:
Verification methods:

 [1.js]:  parttern.test (Val) or parttern.match (val) or parttern.exec (val)

  const parttern = /xxx/
  const val = 'xxxx'

  【2.php】:  preg_match($parttern,$val)
  $parttern = "/xxx/"
  $val = "xxx"
 
1. The beginning and end of the restriction parameters: must be such as $ {xxx} Format
/ ^ \ $ \ {\ W + \} $ / // ^ indicates the start should be xxx, within the brackets is the opposite meaning. That does not appear xxx

2. Restrict the number of repetitions:

/ ^ [A-zA-Z0-9 _] {1,} $ / // {} denotes the number of repetitions, i.e. content of at least one of the left
 / ^ [A-zA-Z] [a-zA-Z0-9 -] {0,} $ / // 0 at least in English, numbers, short bar (-)

3. Size limit values:

 
  
 / ^ ([1-9] [0-9] {0,1}) $ | ^ ([1-2] [0-3] [0-9]) $ | ^ 240 $ | ^ \ $ \ { \ w + \} $ / // must be an integer greater than 0 or less than 240 in the format $ {key}
 
  
 / ^ ([0-9] [0-9] {0,1}) $ | ^ 100 $ | ^ \ $ \ {\ w + \} $ / // or format must be between 0-100 $ {key }

4. Complex check

 /(?=.*\(.*\)|.*(.*))^[a-zA-Z0-9\u4e00-\u9fa5()()]*$|^[a-zA-Z0- 9 \ u4e00- \ u9fa5] * $ / // allowed only in English, numbers in parentheses (must be paired), and underscores

 Third, the data conversion and filtering

Mix of methods:

STR .replace ( '', '\ n-') 2 // replacement string, replace the spaces with newline

 STR. Replace (/ XXX /, '') // check performed by the regular replacement

(Str || '') .replace (/ "connectionId" \: "[\ S] +" / g, '') // designated contents removed
str.replace (/ \ S / IG, '')   // remove all spaces
str.replace (/, / G, ',') // Chinese comma into comma
   function deleteJson (value) {
      let result = ''
      let lines = value.split('\n')
      lines.forEach(val => {
        let n = val.indexOf('//')
        let str = n === -1 ? val : val.substring(0, n)
        str.trim()
        result += str
      })
      return result
    }

 stringObject.replace(regexp/substr,replacement)

Str.replace (/ \ B \ W + \ B / G, function (Word) {// first letter capitalized into
   return word.substring (0,1) .toUpperCase () word.substring + (. 1 );} 
  );

 

Guess you like

Origin www.cnblogs.com/wheatCatcher/p/11287949.html