How to validate your password with regex

## Example password validation regex
- rules below can be concatenated 

```
^(?=.*?[^a-zA-ZÄÖÜäöüß0-9])(?=.*?[0-9])(?=.*?[a-zäöüß])(?=.*?[A-ZÄÖÜ])(?!.*\d{2,}).{8,}$
```

### Special character matching
- Matches (operator is `?=`) any string that has at least a special character e.g.: `sadsds@asdasd`
``` 
(?=.*?[^a-zA-ZÄÖÜäöüß0-9])
```

### Number matching
- Matches (operator is `?=`) any string that has at least a number: e.g.: `s1adsdsasdasd`
```
(?=.*?[0-9])
```

### Small letter matching
- Matches (operator is `?=`) any string that has at least a small letter: e.g.: `SADSa`
```
(?=.*?[a-zäöüß])
```

### Big letter matching
- Matches (operator is `?=`) any string that has at least a big letter: e.g.: `SADSa`
```
(?=.*?[A-ZÄÖÜ])
```


### Consecutive numbers matching
- Doesn't match (operator is `?!`) strings that have consecutive numbers in them: e.g.: asdasd42dada
```
(?!.*\d{2,})
```


### Sequential numbers matching (cannot be used at the same time with previous rule)
- Doesn't match (operator is `?!`) strings that have sequential numbers in them: e.g.: 12asdasd42dada
- It will allow numbers that are separated by other letters e.g.: adasd1asd2asd3
- It will allow consecutive numbers e.g.: ahadADS22dhsg44
```
(?!.*((12)|(23)|(34)|(45)|(56)|(67)|(78)|(90)|(01)))
```

### Length of string matching (should be placed last)
- This will match any string that is less than 8 characters
```
.{8,}
```

Zeno Popovici
27 Aug 2019
« Back to post