$re = '/\b(\w+)\s+{\s+type\s+(\w+);/';
$str = 'geometry
{
hvac
{
type wall;
inGroups 1(wall);
nFaces 904403;
startFace 38432281;
}
OUTLET
{
type patch;
nFaces 8228;
startFace 39336684;
}
INLET
{
type patch;
nFaces 347;
startFace 39344912;
}
Lamelle
{
type wall;
inGroups 1(wall);
nFaces 204538;
startFace 39345259;
}
duct
{
type wall;
inGroups 1(wall);
nFaces 535136;
startFace 39549797;
}
wall
{
type wall;
inGroups 1(wall);
nFaces 118659;
startFace 40084933;
}
}';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php