2019 before the phone number to verify correct expression

The front end of the regular expression validation is often the most numerous and most complex, so recently compiled some of their common regular expressions, hoping to be helpful to everyone!

1  / * valid URI * / 
2 Export function validateURL (textval) {
 . 3    const urlregex = / ^ (?: HTTP (S):? \ / \ /)? [\ W .-] + (:?. \ [\ W \ .-] +) + [\ W \ - \ ._ ~:? / # [\]! @ \ $ & ' . \ * \ +,; =] + $ /
 . 4    return urlregex.test (textval)
 5  }
 . 6  
. 7  / lowercase * * /
 . 8  Export function validateLowerCase (STR) {
 . 9    const REG = / ^ [AZ] + $ /
 10    return reg.test (STR)
 . 11  }
 12 is  
13 is  / uppercase * * /
 14  Export validateUpperCase function (STR) {
 15    const REG = / ^ [AZ] + $ /
 16   reg.test return (STR)
 . 17  }
 18 is  
. 19  / lowercase letters * * /
 20 is  Export function validateAlphabets (STR) {
 21 is    const REG = / ^ [A-Za-Z] + $ /
 22 is    return reg.test (STR)
 23  }
 24  
25  / * market price * /
 26 is  Export function validatePrice (STR) {
 27    (? = const REG /. ^ [1-9] \ D * (\ \ D {1,2}) $) | ( 0 ^ (\. \ D {1,2})? $) /
 28    return reg.test (STR)
 29  }
 30  
31 is  / * Stock warning non-negative integer values match (positive integer 0 +) * /
 32  Export function validatestockWarn (STR) {
 33 is    const REG = / ^ (0 | [1-9] [0-9] *) $ /
 34 is   reg.test return (STR)
 35  }
 36  
37 [  / * Search site only and verification jingdong suning site * /
 38 is  Export function validateCompareWebsite (STR) {
 39    const REG = / ^ ((HTTPS \: \ / \ / [0-9a . -zA-Z \ _] + \ | http \: \ / \ / [0-9a-zA-Z \ _] + \ | https \:. \ / \ / | http \: \ / \ /) | ([0-9a-zA-the Z \ _] + \.) {0,1}) (JD | Suning) \ (COM $ |. COM \ / [\ S] *) / I
 40    return reg.test ( STR)
 41 is  }
 42 is  
43 is  / landline * * /
 44 is  Export function validateTelephone (STR) {
 45    const REG = / ^ (\ (\ D {3,4-} \) | \ D {3,4-} - | \ S )? \ {D} $ 7,14 /
 46 is    return reg.test (STR)
 47  }
 48  
49  / * phone number * /
 50 validatePhoneNumber function Export (STR) {
 51 is    const REG = / ^ [. 1] [3,4,5,6,7,8,9] [0-9] {} $. 9/
 52 is    return reg.test (STR)
 53 is  }
 54 is  
55  / * and landline phone number * /
 56 is  Export function validatePhTelNumber (STR) {
 57 is    const REG = / ^ ((0 \ D {2,3} - \ D {7, 8}) | (. 1 [3456789 ] \. 9 {D})) $ /
 58    return reg.test (STR)
 59  }
 60  
61 is  / * E-mail * /
 62 is  Export function validateEmail (STR) {
 63 is    const REG = / ^ [A-Za-Z0-9 \ u4e00- \ u9fa5] @ + [A-zA-Z0-9 _-] + (\. [A-zA-Z0-9 _-] +) + $ /
 64    return reg.test (STR)
 65  }
 66  
67 / * ZIP * /
 68  Export function validateZipCode (STR) {
 69    const REG = / ^ [1-9] [0-9] {} $. 5/
 70    return reg.test (STR)
 71 is  }
 72  
73 is  / ID * * /
 74  Export function validateIDCard (STR) {
 75    const REG = / (^ \ D {15} $) | (^ \ D {18 is} $) | (^ \ D {. 17} (\ D | X-| X) $) /
 76    return reg.test (STR)
 77  }
 78  
79  / * 15 or bank card 16 or 19 * /
 80  Export function validateBank (STR) {
 81    const REG = / ^ ([1-9] { }. 1) (\ D {14} | \ 18 is {D} | \ D {15}) $ /
 82    return reg.test (STR)
 83  }
 84  
85 / * Taxpayer identification code * /
 86  Export function validateTaxpayer (STR) {
 87    const REG = / ^ ([1-9]. 1 {}) (\ D {14} | \ 18 is {D} | \ D {15} ) $ /
 88    return reg.test (STR)
 89 }

If wrong, please enlighten, thank you!

Guess you like

Origin www.cnblogs.com/megatron817/p/10931193.html