re = /\b\d{1,2}(?:\.\d{1,2}\.|\h+\p{Lu}\p{Ll}+\h+)(?:\d\d|\d{4})\b/m
str = '01.01.2022
1.01.2022
1.1.2022
1.1.22
...
Now I have a date format like this:
25 März 2023
or
25 March 2023'
# 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