re = /\w+(?:-\w+)+/m
str = 'some number L-BSC-MAP-01 - some other words
V-A - some other words
some number L-BFC-MAP-05 some other words - some other words
some number V-B some other words
some number L-BFC-MAD-04 some other words'
# 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