dimanche 10 juillet 2022

Golang positive lookahead alternative

I need to add a password check pattern to the json schema that Golang handles.

  • At least one digit At least one lowercase character
  • At least one uppercase character
  • At least one special character
  • At least 8 characters in length, but no more than 32.

The pattern doesn't work because Golang doesn't support positive lookahead

^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[#%$!*+=_@-])[A-Za-z0-9#%$!*+=_-]{8,32}$

How to change the pattern to keep the password verification conditions and not use positive lookahead.

Aucun commentaire:

Enregistrer un commentaire