0

I'd like to set a pattern for the password on Sylius. I'd like :

  1. 8 characters (min)
  2. 1 lowercase (min)
  3. 1 uppercase(min)

So I made this regular expression :

^(?=.*[A-Z])(?=.*[a-z]).{8,}$

However I don't know where I have to put it to set my password condition

Thank you for your time

N.Jourdan
  • 590
  • 2
  • 4
  • 22

1 Answers1

1

Hope this regex will help you out.

Regex: ^(?=.*[a-z])(?=.*[A-Z]).{8,}$

1. ^ starting of string

2. (?=.*[a-z]) Positive look ahead for lowercase character

3. (?=.*[A-Z]) Positive look ahead for uppercase character

4. .{8,}$ Match 8 or more characters till the end.

Regex demo

PHP code: Try this code snippet here

<?php
ini_set("display_errors", 1);
$string="SahilGul";
if(preg_match('/^(?=.*[a-z])(?=.*[A-Z]).{8,}$/', $string))
{
    echo "Password pattern matched";
}
Community
  • 1
  • 1
Sahil Gulati
  • 15,028
  • 4
  • 24
  • 42