Hi!
Do they mean this?
$string="This is my data (want to keep this data) (want to delete this data and brackets)";
preg_match_all('#\([^\)]*\)#', $string, $matches);
print_R($matches[0][0]."<br>"); //(want to keep this data)
print_R($matches[0][1]."<br>"); //(want to delete this data and brackets)
$string = preg_replace('#\('.$matches[0][1].'\)#' ,"",$string);
print_R($string); //This is my data (want to keep this data)
or always the last matches:
$string="This is my data (want to keep this data) (want to delete this data and brackets)";
preg_match_all('#\([^\)]*\)#', $string, $matches);
$last_match = array_pop($matches[0]);
$string = preg_replace('#\('.$last_match.'\)#' ,"",$string);
print_R($string);//This is my data (want to keep this data)
mfg Andi