re = /^\$\$(?<uid>\d{9})\,(?<ev>\d{4})\,(?<d>\d{2}\/\d{2}\/\d{4})?\,(?<t>\d{2}\:\d{2}\:\d{2})\,(?<lt>\-?\d{1,3}\.?\d{1,6})\,(?<ln>\-?\d{1,3}\.?\d{1,6})\,(?<al>\-?\d{1,7})\,(?<sp>\d{1,3}\.?\d{0,3})\,(?<hd>\d{1,4})\,(?<sv>\d{1,2})\,(?<hp>\d{1,3}\.?\d{1,2})\,(?<bv>\d{1,5}\.?\d{1,4})\,(?<cq>\d{1,2})\,(?<mi>\d*)\,(?<gs>[012345]{1})\,(?<gt>\d{1,5}\.?\d?)\,(?<ac>\-?\d{1,3}\.?\d{0,3})\,(?<dc>\-?\d{1,4}\.?\d{0,3})\,(?<in1s>[01]{1})\,(?<in1a>\d*)\,(?<in2s>[01])\,(?<ig>[012])\#\#/m
str = '$$183900057,4002,03/05/2019,22:23:57,33.093139,-97.132556,2213,0.0,0,9,2.3,13.967,27,0,3,0,0.0,0.0,0,0,0,2##'
# 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