re = /\b\d{10}.*?(?=\b\d{10}|$)/m
str = '8770304350 PRINTER 4610-2CR W/IRON GRAY COVERS (2921) $750.75 2881057001 PAYMENT DEVICE - VERIFONE MX915 - WALMART CONSIGNE 8770242020 DISPLAY 4820-5GB USB W/ I/O SUPPORT IRON GRAY $907.27 8770242216 KEYPAD-MSR 3 TRACK IRON GREY $213.85 2881037020 CONSIGNED- SCANNER DS6878-SR20117WR IMAGER 2D BLUE'
# 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