dataframe - Grep in R (zero or any character) -
i have files lot of data, in several of them date in format: yyyymmdd, f. e. 20150704
and in others date in format: yyyy-mm-dd, f. e. 2015-07-04
i want grep find specific date, can 1 grep both examples?
i tried this:
grep("*07*04",file)
and this
grep(".07.04",file)
second form worked format yyyy-mm-dd not yyyymmdd
is there way 1 grep?
try
grep('-?07-?04$', str1)
data
str1 <- c('2015-07-04', '20150704', '2014-08-07', '20150407', '2015-07-14', '2015-01-04')
Comments
Post a Comment