re = /\d{1,2}.\d{1,2}.20\d{2}/m
str = 'Example 1 (Colon)
Payee: John Smith
Account No: 145-567-981
Date: 19.01.2020
Time: 08:01
Email: JohnSmith@gmail.com
Example 2 (the dash)
John Smith - Payee
145 567 981 - Account No
19-01-2020 - Date
08:01 - Time
John.Smith@hotmail.com - Email
Example 3 (the dashes AND all one line of text)
Payee - John Smith - Account No - 145.567.9815 - Date - 19,1,2020 - Time - 08:01 - Email - John.Z.Smith@yahoo.com'
# 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