re = /(?mis)^\bgeneral( #[0-9])?(.*?)^\s*$/
str = 'General
Complete name : C:\\Projects\\Foray\\MediaEngine\\SampleMedia\\flv\\small.flv
Format : Flash Video
File size : 296 KiB
Duration : 5s 560ms
Overall bit rate mode : Variable
Overall bit rate : 436 Kbps
Writing application : Lavf52.103.0
Video
Format : Sorenson Spark
Codec ID : 2
Duration : 5s 560ms
Bit rate : 781 Kbps
Width : 320 pixels
Height : 240 pixels
Display aspect ratio : 4:3
Frame rate mode : Constant
Frame rate : 25.000 fps
Bit depth : 8 bits
Bits/(Pixel*Frame) : 0.407
Stream size : 530 KiB
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 2
Codec ID/Hint : MP3
Duration : 5s 512ms
Bit rate mode : Variable
Bit rate : 63.8 Kbps
Channel(s) : 1 channel
Sampling rate : 44.1 KHz
Compression mode : Lossy
Stream size : 42.9 KiB (14%)
'
# Print the match result
str.match(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