- preg_match: documentation ( source)
- var_export: documentation ( source)
- preg_split: documentation ( source)
<?php
$strings = ["(AAA/)(BBB/)(cc)", "(AAA/)xxxx(BBB/)(cc)"];
foreach ($strings as $string) {
if (!preg_match('~^(?:\([\w\\/-]+\))+$~', $string)) {
echo "The simple pattern $string is not valid!";
// throw new \Exception("The simple pattern $string is not valid!");
} else {
var_export(preg_split('~\)\K~', $string, 0, PREG_SPLIT_NO_EMPTY));
}
echo "\n";
}