re = /(\d{2}:\d{2}:\d{2}:\d{3}).+(\[.{55}])/
str = '03712 -R->13:29:23:265 uRD 778 ReadStat 20,01,00,[OS:T------- OP:----B--- TS:----- - ---** --*---* ****--]01,9a,80,08,0a,13,00,64,7c,00,14,10,11,01,01,00,00,00,00,00,03,00,00,00,00,00,00,c9,21,00,aa,12,11,00,00,10,0a,bb,01,00,03,01,00,00,cc,01,00,01,01,00,00,01,01,dd,08,27,3b,02,00,02,ee,1a,02,80,00,00,ff,00,aa,01,00,03,00,01,00,00,00,rc=00'
# 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