$re = '/(object)|(: .*)|(end)|(?! On)( .*)/m';
$str = 'object field: TMemo
Left = 6
Top = 23
Width = 390
Height = 156
Anchors = [akLeft, akTop, akRight, akBottom]
ScrollBars = ssVertical
TabOrder = 1
OnChange = fieldChange
OnKeyUp = fieldKeyUp
AddMenu = True
RightClickMoveCaret = True
RightEdge = 0
end
object btn: TButton
Left = 5
Top = 3
Width = 89
Height = 21
Caption = \'Button\'
TabOrder = 0
TabStop = False
OnClick = btnClick
end';
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