Tell if a string starts with any of a vector of strings
starts_with_any_of.Rd
This function returns TRUE
if x
starts with any of the strings in target
and FALSE
otherwise.
Value
TRUE
if x
starts with any of the strings in target
,
FALSE
otherwise.
If x
is a vector or list of strings,
the return value is a vector of the same length as x
containing the result of applying the test to each item in x
.
Details
This function is vectorized. If x
is a vector or list of strings,
the return value has the same length as x
and contains the result
of applying the test (does x
start with any of target
)
for each item in x
.
target
can be either a vector or a list.
To allow target
to be a list,
target
is unlist()
ed before use.
Examples
starts_with_any_of(x = "prefix - suffix", target = c("a", "b", "prefix"))
#> [1] TRUE
starts_with_any_of(x = "prefix - suffix", target = c("a", "b", "c"))
#> [1] FALSE
starts_with_any_of(x = "prefix - suffix", target = "suffix")
#> [1] FALSE
starts_with_any_of(x = c("Production - Crude", "Production - NG",
"Exports - Oil", "Exports - Crude"),
target = c("Production", "Imports"))
#> [1] TRUE TRUE FALSE FALSE