Example:
$match_check = "(?'txt'(?<=:txt{)([^}]+)(?=}))|(?'reg'(?<=:reg{)([^}]+)(?=}))";
$route_from_value = ':txt{resultxt}:txt{test}:reg{/^[a-zA-Z]*$/}:reg{regexresult}';
preg_match_all('/'.$match_check.'/', $route_from_value, $get_matchers_check);
var_dump($get_matchers_check);
And result for given question are:
array(7) {
[0] =>
array(4) {
[0] =>
string(8) "resultxt"
[1] =>
string(4) "test"
[2] =>
string(13) "/^[a-zA-Z]*$/"
[3] =>
string(11) "regexresult"
}
'txt' =>
array(4) {
[0] =>
string(8) "resultxt"
[1] =>
string(4) "test"
[2] =>
string(0) ""
[3] =>
string(0) ""
}
[1] =>
array(4) {
[0] =>
string(8) "resultxt"
[1] =>
string(4) "test"
[2] =>
string(0) ""
[3] =>
string(0) ""
}
[2] =>
array(4) {
[0] =>
string(8) "resultxt"
[1] =>
string(4) "test"
[2] =>
string(0) ""
[3] =>
string(0) ""
}
'reg' =>
array(4) {
[0] =>
string(0) ""
[1] =>
string(0) ""
[2] =>
string(13) "/^[a-zA-Z]*$/"
[3] =>
string(11) "regexresult"
}
[3] =>
array(4) {
[0] =>
string(0) ""
[1] =>
string(0) ""
[2] =>
string(13) "/^[a-zA-Z]*$/"
[3] =>
string(11) "regexresult"
}
[4] =>
array(4) {
[0] =>
string(0) ""
[1] =>
string(0) ""
[2] =>
string(13) "/^[a-zA-Z]*$/"
[3] =>
string(11) "regexresult"
}
}
But, expected result should be (how make it only with regexp?) or something simply:
'txt' =>
array(4) {
[0] =>
string(8) "resultxt"
},
'txt' =>
array(4) {
[0] =>
string(8) "resultxt"
}
'reg' =>
array(4) {
[0] =>
string(8) "/^[a-zA-Z]*$/"
}
'reg' =>
array(4) {
[0] =>
string(8) "regexresult"
}