Can someone explain to me why the following returns empty arrays?
$reg = "/(\[{(false|true)};{.+};{\d}\])+/";
preg_match_all($reg,"[{false};{abcde};{10}][{true};{fghij};{10}]",$matches);
print_r($matches);
Can someone explain to me why the following returns empty arrays?
$reg = "/(\[{(false|true)};{.+};{\d}\])+/";
preg_match_all($reg,"[{false};{abcde};{10}][{true};{fghij};{10}]",$matches);
print_r($matches);
You've written \d
when it should be \d+
:
$reg = "/(\[{(false|true)};{.+};{\d+}\])+/";
preg_match_all($reg,"[{false};{abcde};{10}][{true};{fghij};{10}]",$matches);
print_r($matches);
Although it doesn't seem to matter in your case, I'd also escape the braces, as they are special characters.
$reg = "/(\[\{(false|true)\};\{.+\};\{\d+\}\])+/";