re = /^(?P<KEY>[^=#\s]+)=(?P<VALUE>.*)$/m
str = 'app=tcp/444
# Catchs only Key:app Value:tcp > should catch Key:app Value:tcp/444
catdt=Network-based
# Current result:
# catdt:\'Network\'
#
# Shoud be:
# catdt:\'Network-based\'
eventId=123123 externalId=11111
# Current result:
# eventId:\'123123 externalId=11111\'
#
# Should catch
# eventId: \'123123\'
# externalId: \'111111\'
src=2.3.4.5
# Current result:
# src:\'2\'
#
# Should catch
# src: \'2.3.4.5\'
eventAnnotationEndTime=1493293598\\=aaa00
# Should be:
# eventAnnotationEndTime: \'1493293598\\=aaa00\'
eventAnnotationEndTimeA=1493293598A\\=aaa01
eventAnnotationEndTimeB=1493293598\\=aaa02
# Should be:
# eventAnnotationEndTimeA: \'1493293598\\=aaa01\'
# eventAnnotationEndTimeB: \'1493293598\\=aaa02\'
sourceTranslatedZoneURI=/All Zones/ArcSight System/Private Address Space Zones/RFC1918: 172.3.0.0-172.3.255.255
# Should be:
# ourceTranslatedZoneURI: \'/All Zones/ArcSight System\''
# 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