Il semble que votre avoir du mal à comprendre ce que DTB essaie de dire. Permettez-moi de DECOMPOSENT la regex pour vous et vous verrez ce qu'il dit:
^ - 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
[email protected]#$%^&*()-_=+;:'"|~`?/{} - 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
C'est là votre expression se dérègle ...
| - 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
Donc (si je lis ce correctement) vos états d'expressions rationnelles:
"Je fais correspondre une chaîne si la chaîne commence par des caractères ascii et a entre 3 et 16 caractères avant de trouver la fin de la chaîne ou un espace (tabulation ou espace)."
Pour résoudre ce problème, supprimez le « | \ » s de la fin de votre expression et il suffit d'utiliser les éléments suivants:
^([[email protected]#$%^&*()-_=+;:'"|~`<>?/{}]{3,16})$
C'est l'expression, où est le code? Si l'expression est correcte, il s'ensuit que le code doit être faux. Ou peut-être le compilateur, mais ne comptez pas dessus. –
C'est juste un lié à une boîte de texte –
David