re = /^Maximum amplitude:\s*(-?\d\.\d+)\n/m
str = 'Samples read: 6615000
Length (seconds): 75.000000
Scaled by: 2147483647.0
Maximum amplitude: 0.712219
Minimum amplitude: -0.805969
Midline amplitude: -0.046875
Mean norm: 0.009264
Mean amplitude: -0.000027
RMS amplitude: 0.043011
Maximum delta: 0.734100
Minimum delta: 0.000000
Mean delta: 0.008353
RMS delta: 0.041470
Rough frequency: 6767
Volume adjustment: 1.241'
# 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