re = /^[^\[]+\[[^\]]+\]\s+\[(?<log_level>[^\]]+)\]\s+\[[^\]]*\]\s+(?<your_field>[^\]]+)/m
str = '{"log":"[10:30:04.075] [INFO ] [] [c.c.n.b.i.DefaultBusinessEventService] [akka://MmsAuCluster/system/sharding/notificationAuthBpmn/4/nmT9K3rySjyoHHzxO9jHnQ_4/nmT9K3rySjyoHHzxO9jHnQ] - method=prepare; triggerName=approvalStart, entity={\'id\'=\'0f86c9007ff511ed82ffd13c4d1f79a9a07ff511ed82ffd13c4d173b0a\',\'eventCode\'=\'approval\',\'paymentSystemId\'=\'MMS\',\'servicingAgentBIC\'=\'null\',\'messageIdentification\'=\'0f86ff511ed82ffd13c4d173b0a\',\'businessDomainName\'=\'Mandate\',\'catalogCode\'=\'AN\',\'functionCode\'=\'APAL_INTERACTION\'}'
# 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