Description Usage Arguments Value Examples
View source: R/str_extract_before_date.R
Vectorised over 'string' and 'date_sep'.
1 | str_extract_before_date(string, date_sep = "", format = "num", num_char = NULL)
|
string |
The string from which to extract. |
date_sep |
Character symbol seperating the components of the date. |
format |
The format of the date in the string. Must be one of 'num' (year-month-day, month-day-year, or day-month-year with all numerical components), 'mdy-abbr' (month-day-year, abbreviated month name), 'dmy-abbr' (day-month-year, abbreviated month name), 'mdy-full' (month-day-year, full month name), or dmy-full' (day-month-year, full month name). |
num_char |
The number of characters to return from before the pattern. Leave NULL to return everything before the pattern. |
The part of the string before the pattern.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | test_string <- 'url.com/string_before_pattern_2020_08_01/index.html'
str_extract_before_date(string = test_string, date_sep = "_")
str_extract_before_date(string = test_string, date_sep = "_", num_char = 21)
test_string <- 'really-long-file-name-12-31-2020.csv'
str_extract_before_date(string = test_string, date_sep = "-")
test_string <- 'really-long-file-name-Mar-18-2018.csv'
str_extract_before_date(string = test_string, date_sep = "-", format = "mdy-abbr")
test_string <- 'really-long-file-name-March-18-2018.csv'
str_extract_before_date(string = test_string, date_sep = "-", format = "mdy-full")
test_string <- 'really-long-file-name-28-Mar-2018.csv'
str_extract_before_date(string = test_string, date_sep = "-", format = "dmy-abbr")
test_string <- 'really-long-file-name-28-March-2018.csv'
str_extract_before_date(string = test_string, date_sep = "-", format = "dmy-full")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.