$re = '/(?<entry>@(\w+)\{(\w+),(?<kvp>\W*([a-zA-Z]+) = \{(.+)\},)(?&kvp)*(\W*([a-zA-Z]+) = \{(.+)\})\W*\},?\s*)(?&entry)*/';
$str = '@article{Gettys90,
author = {Jim Gettys and Phil Karlton and Scott McGregor},
abstract = {A technical overview of the X11 functionality. This is an update of the X10 TOG paper by Scheifler \\& Gettys.},
journal = {Software Practice and Experience},
volume = {20},
number = {S2},
title = {The {X} Window System, Version 11},
year = {1990}
},
@article{Gettys90,
author = {Jim Gettys and Phil Karlton and Scott McGregor},
abstract = {A technical overview of the X11 functionality. This is an update of the X10 TOG paper by Scheifler \\& Gettys.},
journal = {Software Practice and Experience},
volume = {20},
number = {S2},
title = {The {X} Window System, Version 11},
year = {1990}
},
@article{Gettys90,
author = {Jim Gettys and Phil Karlton and Scott McGregor},
abstract = {A technical overview of the X11 functionality. This is an update of the X10 TOG paper by Scheifler \\& Gettys.},
journal = {Software Practice and Experience},
volume = {20},
number = {S2},
title = {The {X} Window System, Version 11},
year = {1990}
}';
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