I'm trying to extract a certain portion of the text in a column - I only want the text between the first and second whitespace - in this case the manufacture year. The field is in column "Detail" within the dataframe "data". This is the structure which is consistent:
Used 2014 Toyota Camry
I'm only interested in capturing the "2014" within this field:
Here is what I've tried:
sub(".*?\\s+(.*)\\s.*", "\\1", "Used 2014 Toyota Camry", perl=TRUE)
Help is much appreciated.