i need to pull some segments out of a file (loaded into a variable)
the segments i need to pull out is basically anything in brackets
what makes its esp hard is the brackets are not your standard () [] or {}, the closing bracket character is in fact two characters
for example
from the string:
£a£b£c!£d!£e!£ f £g!£
where £ equates to (
and !£ equates to )
i want to extract
£a£b£c!£d!£e!£
and
£g!£
as matches
so far i have got to:
$string = " §b§c;§d;§";
if(preg_match_all("/(?<!§([^()]+|(?R))*(?<=§/U",$string,$matches)) {
echo "<pre>"; print_r($matches[0]); echo "</pre>";
}
which returns
Array
(
[0] => £a£b£c!£
[1] => £g!£
)
the first match is missing the d and e parts
Any clues on a solution would be really appreciated