I need to match following pattern using php Regular expression but it doesn't give expected out come.
ex:- need to match pattern 5555 5545 9930
$id = "4567 3423 4567";
$regex = "/^[1-9]\d{4} \d{4} \d{4}$/";
if (preg_match($regex, $id)) {
// Indeed, the expression "^[2-9]\d{2} \d{3} \d{4}$" matches the date string
echo "Found a match!";
}else {
// If preg_match() returns false, then the regex does not
// match the string
echo "The regex pattern does not match. :(";
}
"/^[2-9]\d{2,3} \d{3,4} \d{4}$/"or - if you do not want to match mixed input types -"/^(?:[2-9]\d{2} \d{3}|\d{4} \d{4}) \d{4}$/"