re = /^[^'\n\r]*On Error Goto/mi
str = 'Match:
on error goto err_handler
if aap = 0 then on error goto Myerrorhandler
on error goto errorhandler1
on error goto errorhandler2
Do not match:
\' on error goto errorhandler3
\' if aap =0 then on error goto errorhandler4
Any line not containing On Error Got0'
# 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