How to write such a regexp for js?
-
Good day. Help write such a check for inputs. Interested in regexp with the following restrictions:
and the second
JavaScript Isaiah Simpson, Jan 21, 2020 -
Regulars for such idiotic conditions are written stupidly. Look ahead preview masks are used - (= and (!
- minimum 7 characters (? =. {7})
- maximum 64 characters (?!. {65})
- only Latin is allowed - the most idiotic. Clarification is required, in German, or in hieroglyphs, so you can? Let's assume that Russian letters are prohibited - (?!. * [ЁЁа-я])
- must not contain ... - (?!. * [! @ # $% ^ & amp; *?])
- you cannot enter 4 identical characters. This is also a condition ... 4 commas in a row, so you can? Let's assume that any 4 in a row is impossible - (?!. * (.) \ 1 \ 1 \ 1)
- combinations of qwerty - (?!. * qwert)
- combinations 1234 - (?!. * 1234)
- does not match the word password - (?! password $)
- must not contain spaces (?!. * \ s)
Total - we unite and tadams!
let reg=/^(?=.{7})(?!.{65})(?!.*[ёЁа-я])(?!.*[[email protected]#$%^&\*\?])(?!.*(.)\1\1\1)(?!.*qwert)(?!.*1234)(?!password$)(?!.*\s).*/i
You can get by with fewer letters, but is it worth it. Readability is important in this matter.
Can you do the second example yourself?Anonymous
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!