<?php
$str = '123-12-123';
preg_match('/\d{3}\-\d(\d\-\d{3}|)/', $str, $matches);
var_dump($matches);
$str = '1-1-1';
preg_match('/\d{3}\-\d{2}\-\d{3}/', $str, $matches);
var_dump($matches);
- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- array(2) {
[0]=>
string(10) "123-12-123"
[1]=>
string(5) "2-123"
}
array(0) {
}
preferences:
156.88 ms | 407 KiB | 5 Q