我正在尝试解密用于表单验证的正则表达式文件,而且我必须列出每个字段的所有可接受的字符和字符数,并且已获得一个正则表达式文件来执行此操作。
我已经制定了一些规则,但是我对regex不太满意,并希望确保所有内容都正确。
以下是正则表达式:
{
"lastName": "^(?=.{1,30}$)[A-Za-z`\\u0027\\- ]*$",
"country": "^(AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BQ|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CW|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|PT|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SX|SK|SI|SB|SO|ZA|GS|SS|ES|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW)$",
"city": "^(?=^.{1,64}$)[A-Za-z \\-/&#,]*$",
"postalCode": "^[0-9]{5}(?:-[0-9]{4})?$",
"companyName": "^(?=.{0,45}$)[\\]A-Za-z0-9 $\\^~`<>+-_=\\u0027\\[#\\$%&*\\(\\)\\.,\\?\\\\]*$",
"customFieldEmail": "(?=^.{1,50}$)(^[a-zA-Z0-9!#$%&\\u0027*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&\\u0027*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+([a-zA-Z]{2,})$)",
"tributeFrom": "^(?=.{1,60}$)[A-Za-z0-9!#$%&\\u0027*+/=?^_`\\u0027{|}~\\\\\\-@. ]*$",
"tributeEmailSubject": "^(?=.{1,50}$)[A-Za-z0-9!#$%&\\u0027*+/=?^_`{|}~\\\\\\-@. ]*$",
"tributeMessage": "^([\\S\\s]{1,250})$",
"tributeMailMessage": "^([\\S\\s]{1,80})$",
"state": "^(?:A[KLRZAPES]|C[AOT]|D[CE]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])*$",
"email": "(?=^.{1,50}$)(^[a-zA-Z0-9!#$%&\\u0027*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&\\u0027*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+([a-zA-Z]{2,})$)",
"cvv3": "^[0-9]{3,3}$",
"cvv4": "^[0-9]{4,4}$",
"cvv": "^[0-9]{3,4}$",
"tributeName": "^(?=.{1,60}$)[\\]A-Za-z0-9 $\\^~`<>+-_=\\u0027!@\\[#\\$%&*\\(\\)\\.,\\?\\\\]*$",
"passwordStrong": "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[\\\\.\\\\,\\\\;\\\\:\\\\@\\\\№\\\\#\\\\$\\\\%\\\\&\\\\*\\\\+\\\\=\\\\?\\\\!\\\\^\\\\\\\\\\/\\\\|\\\\-\\\\_\\\\~\\\\\"\\\\'\\\\`\\\\(\\\\)\\\\{\\\\}\\\\[\\\\]])(?=\\S+$).{12,64}$",
"address2": "^[A-Za-z0-9 \\-/&#,.]{0,128}$",
"address1": "^[A-Za-z0-9 \\-/&#,.]{1,128}$",
"billCity": "^(?=^.{1,50}$)[A-Za-z \\-/&#,]*$",
"firstName": "^(?=.{1,30}$)[A-Za-z`\\u0027\\- ]*$",
"phoneNumber": "^[0-9]{1,10}$",
"customFieldFreeForm": ".*$",
"billAddress2": "^[A-Za-z0-9 \\-/&#,.]{0,60}$",
"billAddress1": "^[A-Za-z0-9 \\-/&#,.]{1,60}$",
"creditCard": "^(?:4[0-9]{12}(?:[0-9]{3})?|(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\\d{3})\\d{11})$",
"donationAmount": "^(?=[1-9])\\d{1,5}(?:\\.\\d{2,2})?$",
"passwordWeak": "^(?!(.)\\1{5})(.){6,64}$",
"passwordGood": "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[\\\\.\\\\,\\\\;\\\\:\\\\@\\\\№\\\\#\\\\$\\\\%\\\\&\\\\*\\\\+\\\\=\\\\?\\\\!\\\\^\\\\\\\\\\/\\\\|\\\\-\\\\_\\\\~\\\\\"\\\\'\\\\`\\\\(\\\\)\\\\{\\\\}\\\\[\\\\]])(?=\\S+$).{8,64}$"
}
例如,我可以解密:
Last Name: 30 Characters max and accepts A-Z a-z ' ` space -
是否有一种更简便的方法来解密此文件中包含的所有规则,还是让我梳理文件并查看一切工作原理。我以前从未使用过regex,这是一项对时间敏感的任务,因此我希望尽快完成。
我用过https://regexr.com/-给了我一些但不是全部,并且到处都有文件格式方面的问题。
任何建议或答案将不胜感激