Кажется, у вас проблемы с пониманием того, что пытается сказать ДТБ. Позвольте мне разобрать регулярное выражение для вас, и вы увидите, что он говорит:
^ - matches the beginning of the input string
( - begins a capture group, in your case useless and can be removed along with the closing ) just before the $
[ - begins a group of characters
a-zA-Z0-9!@#$%^&*()-_=+;:'"|~`?/{} - defines all the characters allowed, NOTICE there is no space character so spaces will not count
] - ends the group of characters
{3,16} - says that the preceding character(or group of characters in this case) must occur between 3 and 16 times
) - closes the capture group, again can be removed with the open (
$ - matches the end of the input string
Здесь твое выражение лица искажается ...
| - says that the preceeding match expression (this is the $ which is the end of input) OR the following must be true, but not necessarily both
\s - matches a space or tab anywhere in the input string
Итак (если я правильно читаю) ваше регулярное выражение утверждает:
"Я сопоставляю строку, если строка начинается с символов ascii и имеет длину от 3 до 16 символов, прежде чем она найдет либо конец строки, либо какой-либо пробел (символ табуляции или пробел)."
Чтобы исправить это, удалите '| \ s' из конца вашего выражения и просто используйте следующее:
^([a-zA-Z0-9!@#$%^&*()-_=+;:'"|~`<>?/{}]{3,16})$