My code:
require 'Date'
s = "I'm going away on Oct 2, 2012th"
puts Date.parse(s)
=> 2012-10-02
I want to delete the date from my strings, that I found with Date.parse(s). The problem is, I know that there is a date, but not how it was written in the string. I know that Date.parse found it and converted “2012-10-02” to a new format.
Here is a quick and dirty solution. The function
date_stringreturns just the portion of the string containing the date
found by
parse.This outputs:
So you could do something like: