I'm extracting a string from wikipedia API that initially looks like this:
link text. I want to peel off all {{...}} and everything in between them (could be any kind of text). For that I thought about using a recursive function with "preg_match
","preg_replace
".
something like:
function drop_brax($text)
{
if(preg_match('/{{(.)*}}/',$text))
return drop_brax(preg_replace('/{{(.)*}}/','',$text));
return $text;
}
This function will not work because of a situation like this:
{{ I like mocachino {{ but I also like banana}} and frutis }}
this will peel off everything between the first occurence of both {{ and }} (and leave out "and frutis }}"). How can I do this properly? (while maintaining the nice recursive form).