$re = '/<(\w+)>\s*(.*?)\s*<\/\1>/s';
$str = '<about>
This is an XML file
that I want to
extract data from
</about>
<message>Hello, this is a message.</message>
<this>Blah</this>
<that>Blahh</that>
<person>
<name>Jack</name>
<age>27</name>
<email>jack@gmail.com</email>
</person>';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 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