str_extract_after_date: Extract characters in a string which occur after a date

Description Usage Arguments Value Examples

View source: R/str_extract_after_date.R

Description

Vectorised over 'string' and 'date_sep'.

Usage

1
str_extract_after_date(string, date_sep = "", format = "num", num_char = NULL)

Arguments

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 after the pattern. Leave NULL to return everything after the pattern.

Value

The part of the string after the pattern.

Examples

 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_after_date(string = test_string, date_sep = "_")
str_extract_after_date(string = test_string, date_sep = "_", num_char = 6)

test_string <- 'I-should-use-version-control-12-31-2020-final.csv'
str_extract_after_date(string = test_string, date_sep = "-")

test_string <- 'I-should-use-version-control-Dec-31-2020-final.csv'
str_extract_after_date(string = test_string, date_sep = "-", format = "mdy-abbr")

test_string <- 'I-should-use-version-control-December-31-2020-final.csv'
str_extract_after_date(string = test_string, date_sep = "-", format = "mdy-full")

test_string <- 'I-should-use-version-control-31-Dec-2020-final.csv'
str_extract_after_date(string = test_string, date_sep = "-", format = "dmy-abbr")

test_string <- 'I-should-use-version-control-31-December-2020-final.csv'
str_extract_after_date(string = test_string, date_sep = "-", format = "dmy-full")

johncassil/stringr.plus documentation built on Oct. 9, 2021, 7:56 p.m.