re = /^(?:[^*\n]*\*){2}([^*\n]*)/m
str = 'LLC1R.8888.GR0054656*DR.798012...2..............GR0054656*CNY*ARTIST*
TC1R.88.GR0054656*DR.765012...2..............GR0054656*EUR*LUKE*
K56R.8.GR0054656*DR.258812...4..............GR0054656*AUD*
790GG.88.GR0054656*DR.338012...5..............GR0054656*IDR*MATTHEW*
GREFD.888.GR0054656*DR.198012...6..............GR0054656*'
# 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