$re = '/parent {[\s\S]*type.*[\s\S]*subtype.*[\s\S]*element.*[\s\S]*attributes.*[\s\S]*value testvalue.*[\s\S]*owner person1/m';
$str = 'parent {
type {
subtype TestSubType {
element TestElement {
attributes {
name testname;
description testdescription;
count 1234;
value testvalue;
}
owner person1;
}
}
subtype TestSubType2 {
element TestElement2 {
attributes {
name testname2;
description testdescription2;
count 2;
value 2
}
owner unknown;
}
}
}
}
';
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