0

I want to make sure my users passwords contain at least one, a-z, one A-Z, one 0-9 and one special character.

I thought the best way of doing this would be to set variables like this:

$lower_list = 'abcdefghijklmnopqrstuvwxyz';
$upper_list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$numbers_list = '0123456789';
$special_list = '!"£$%^&*(){}[]=-`¬¦\|/?.>,<#~\'@;:*-+';

Whats the function I need? Or is there a better way of doing it? I know I could use preg_match but I have no idea how to write the regex.

Adam
  • 1,957
  • 3
  • 27
  • 56

1 Answers1

1

maybe this can help:

$pattern = "/^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).*$/";
Bojan Kovacevic
  • 778
  • 7
  • 19