I have a string: "C:/This/is/a/windows/path/file20110312name20120221.csv"
.
I want to extract all dates (e.g. [0-9]{8}
).
Generally, how can I extract sub-strings matching a pattern from a bigger string?
I have a string: "C:/This/is/a/windows/path/file20110312name20120221.csv"
.
I want to extract all dates (e.g. [0-9]{8}
).
Generally, how can I extract sub-strings matching a pattern from a bigger string?
It is advised to supplement your question with a reproducible example (How to make a great R reproducible example?)
Is this what you look for ?
s <- "C:/This/is/a/windows/path/file20110312name20120221.csv"
regmatches(s, gregexpr("[0-9]{8}", s))