I tried to extract a coded string from a string, for instance,
$string = 'Louise Bourgeois and Tracey Emin: Do Not Abandon Me [date]Until 31 August 2011[ /date ]';
$description = preg_replace('/\[(?: |\s)*([date]+)(?: |\s)*\](.*?)\[(?: |\s)*([\/date]+)(?: |\s)*\]/is', '',$string);
$date = preg_replace('/\[(?: |\s)*([date]+)(?: |\s)*\](.*?)\[(?: |\s)*([\/date]+)(?: |\s)*\]/is', '$3',$string);
echo $date;
result:
Louise Bourgeois and Tracey Emin: Do Not Abandon Me /date
intended result:
Until 31 August 2011
I got the $description right but I can’t get the [date] right. Any ideas?
I think a rather simpler form would do:
for instance?