Kannst Du etwas genauer beschreiben was Du machen möchtest? Also villeicht mehrere Beispiele posten.
Das folgende Beispiel findet das p, style und xy:
PHP-Code:
<?php
(string) $str = "{p [style_xy] }";
if (preg_match('/\{(\w)\s+\[(\w+)_(\w+)\](:?\s+)?\}/', $str, $match)) {
echo "Match 1: ".$match[1]."<br/>\n";
echo "Match 2: ".$match[2]."<br/>\n";
echo "Match 3: ".$match[3]."<br/>\n";
}
?>