There are dates like:

November 7, 2006

I tried this:

begin date = Date.parse('7 ноября 2006') rescue ArgumentError date = nil end 

But at the output I get null.

How to parse them in Ruby?

  • There is probably no built-in solution. But if you have a fixed format, you can make find & replace ( String#gsub ) to translate into English, and the problem is solved. If you write, you can post the answer yourself :) - D-side
  • @ D-side Yes, I solved the problem myself, but almost as well. I did not change the name of the month in English, but to the number of the month. But your decision is also the right one. Even, probably, better, because of the uselessness of something like .grep(' ', '/') . - Colibri
  • You do not forget to leave the answer. - D-side

1 answer 1

You can replace the English word (name of the month) with Russian using .grep() , as suggested by @ D-side.

But I only needed to get the numbers, so I used the same function .grep() replace the name of the month with its number, connected and parsed the Date.parse .