re = /^\d{1,2}([ -.\/])(\d{1,2}|[a-zA-z]{3,15})(?1)\d{2,4}( \d{2}:\d{2}(:\d{2}([.:]\d)?)?)?$|^(\d{1,2}|[a-zA-z]{3,15})([ -.\/])\d{1,2}(?7)\d{2,4}( \d{2}:\d{2}(:\d{2}([.:]\d)?)?)?$|^\d{2,4}([ -.\/])(\d{1,2}|[a-zA-z]{3,15})\d{1,2}(?11)( \d{2}:\d{2}(:\d{2}([.:]\d)?)?)?$/m
str = '23/02/1993
23-02/1993
23-fev-1993
fev-23-1993
fev.02.93
28-OCT-90
28-OCT-1990
10/28/90
10/28/1990
28.10.90
dd.mm.yyyy
28.10.1990
90/10/28
yyyy/mm/dd
1990/10/28
4 Q 1990
OCT 90
OCT 1990
01:02
01:02:34.75
02:34
02:34.75
20 08:03
20 08:03:00
20-JUN-1990 08:03
20-JUN-1990 08:03:00
1990-06-20 08:03
1990-06-20 08:03:00.0'
# 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