Adding password validation rule in Laravel

If you want to check if the password contains the following categories:

English uppercase characters (A – Z)

English lowercase characters (a – z)

Base 10 digits (0 – 9)

Non-alphanumeric (For example: !, $, #, or %)

Unicode characters

Create a regular expression first. It would look like this:

^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%]).*$

Then use it in the code . The Laravel code will be like given below:

'password' => 'required|

               min:6|

               regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\X])(?=.*[!$#%]).*$/|

               confirmed',

For Laravel 5.6 the laravel code will be:

'password' => ['required', 

               'min:6', 

               'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\X])(?=.*[!$#%]).*$/', 

               'confirmed']