> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/regex-for-validating-password.md).

# regex for validating password

This regex can be use to validate password

```
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\W]).{8,20})
```

description:

```
(                   # Start of group
  (?=.*\d)          # must contains one digit from 0-9
  (?=.*[a-z])       # must contains one lowercase characters
  (?=.*[\W])        # must contains at least one special character
  .                 # match anything with previous condition checking
  {8,20}            # length at least 8 characters and maximum of 20 
)                   # End of group
```
