I have unstructured data that look like this:
data <- c("24-March-2017 product 1 color 1",
"March-2017-24 product 2 color 2",
"2017-24-March product 3 color 3")
I would like to count number of spaces between the date and the first character (product column) for each line. As shown in the sample data, the date format can vary. This information will be used to put the data into structured format.
What is the best way to perform this in R? I believe gsub can be used in this case, just not sure how to apply to count only number of spaces at the beginning of each line.