$re = '/\s*
(
(?<type>int(?:\s+long|\s+short)?|double(?:\s+long)?|
long(?:\s+int|\s+double)?|short(?:\s+int)?|float|char)
|
(?<error>\w+|\w+\s*\,)
)
\s+
(?:
(?:
(?:
(?<error>int|double|float|char|long|short|[^,;a-zA-Z_].+?|[^,;]+?(?:\s+\w+?)+)
|
(?<id>[a-zA-Z_][a-zA-Z_0-9]*)
)
(?:\s*\[\s*[1-9]\d*\s*\])*
)
\s*
(?:\,\s*|(?=\;))
)+
\s*\;\s*/mx';
$str = 'int
abv, cde, doub1lel,ded, cto, int1;
float ng23423, _ga45,
astories;
int af , f;
int a, b, c;int short alt ;
long double fgd [ 1 ], [1] , wef ;
char _a[1], fi [
3
] [ 10] [ 4 ] ,g[1];int qw;';
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