re = /^(?:(?:(?:(?:0?\d|[12]\d|3[01])\/(?:0?[578]|1[02]))|(?:(?:0?\d|[12]\d|30)\/(?:0?[469]|11))|(?:(?:0?\d|1\d|2[0-8])\/0?2))\/1999|(?:(?:(?:0?\d|[12]\d|3[01])\/(?:0?[13578]|1[02]))|(?:(?:0?\d|[12]\d|30)\/(?:0?[469]|11))|(?:(?:0?\d|1\d|2[0-8])\/0?2))\/200[0-3]|(?:(?:(?:0?\d|[12]\d|3[01])\/(?:0?[13]))|(?:(?:0?\d|1\d|2[0-8])\/0?2))\/2004|29\/0?2\/200[04])$/m
str = '01/04/1999
31/03/1999
29/02/2000
30/02/2000
28/2/2001
29/2/2001
30/4/2002
31/4/2002
31/1/2003
32/1/2003
31/3/2004
01/4/2004'
# 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