<?php $re = '/^(?=.{8,12}$)(?=[^A-Z]*[A-Z])(?=\D*\d)(?=(?:[^a-z]*[a-z]){3})(?=[^\s#*.!?$]*[#*.!?$])(?!.*(.)\1)(?:[a-z]|[A-Z])[a-zA-Z0-9#*.!?$,]+$/m'; $str = 'Abcd123!, Abcd123!, abcD123!,dfe abcD123,dfe abcD122!,dfe'; preg_match_all($re, $str, $matches); print_r($matches[0]); $strings = [ "Abcd123!,", "Abcd123!,", "abcD123!,dfe", "abcD123,dfe", "abcD122!,dfe" ]; $re2 = '/^(?=.{8,12}$)(?=[^A-Z]*[A-Z])(?=\D*\d)(?=(?:[^a-z]*[a-z]){3})(?=[^\s#*.!?$]*[#*.!?$])(?!.*(.)\1)(?:[a-z]|[A-Z])[a-zA-Z0-9#*.!?$,]+$/'; foreach ($strings as $string) { if (preg_match($re2, $string)) { echo "Match for $string" . PHP_EOL; } else { echo "No match for $string" . PHP_EOL; } }
You have javascript disabled. You will not be able to edit any code.