更新时间:2023-02-18 09:19:10
我们使用 str_extract
提取它,然后使用 anydate
提取格式
we extract it using str_extract
and then with anydate
get the format
library(anytime)
library(stringr)
anydate(str_extract_all(str1, "[[:alnum:]]+[ /]*\\d{2}[ /]*\\d{4}")[[1]])
#[1] "2018-07-10" "2018-10-07"
str1 <- "My Friend is coming on july 10 2018 or 10/07/2018"