re = /^[a-z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$/m
str = 'abcd-1234yz
abcd1234yz
abcd1234yz
abcd1234yz
1ca4tc7f-22ab-4d55-91d2-58a821ceb4c4
1ca4tc7f-227b-4d55-91d2-58a821ceb4c42
1ca4tc7f2-227b-4d55-91d2-58a821ceb4c49'
# 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