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'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html