A slight modification of your regexp works(Just add the question mark to make it non-greedy)-
<?php
$input = "This is some text with a {%TAG % }IT%%} and some more text then {%ANOTHER TAG%} with some more text at the end.";
$regexp = "/{%\w+[\w =!:;,\.\$%\"'#\?\-\+\{}]*?%}/";
// ^ Notice this
if(preg_match_all($regexp, $input, $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
var_dump($match);
echo "\r\n";
}
unset($match);
}
/*
Outputs:
array
0 => string '{%TAG % }IT%%}' (length=14)
array
0 => string '{%ANOTHER TAG%}' (length=15)
*/
?>