I am cleaning up a table that contains all sorts of weird naming conventions. One of the names I keep seeing is a string of dates. Some of these names contain numbers which are okay but I would like to remove date formats from the strings.
Edit - Dates are either in mm/YY or mm/YYYY format. The dates are normally from 2017 onwards as I have seen (we want more recent updates).
For example:
names <- c('IT Company 09/18', 'Tech Company 9/17', '9/2018 XYZ Company', '50/50 Phone Company')
Should be:
c('IT Company', 'Tech Company', 'XYZ Company', '50/50 Phone Company')
I tried to use this function here to flag strings with "/" and dates but it also extracts numbers that are not dates:
names2 <- names[grepl("[[:digit:]]", names) & grepl("/", names)]
Output
> names2
[1] "IT Company 09/18"
[2] "Tech Company 9/17"
[3] "9/2018 XYZ Company"
[4] "50/50 Phone Company"
Is there a specific date expression I can use in place of [[:digit:]] to find strings with dates?
Also, what is the function to remove dates including the slash from a string?