I wrote code to extract the date from a given string. Given
> \"Date: 2012-07-29, 12:59AM PDT\"
it extracts
> \"
Regex with backreferencing works:
> sub("^.+([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]).+$","\\1","Date: 2012-07-29, 12:59AM PDT") [1] "2012-07-29"
But @Dirk is right that parsing it as a date is the right way to go.