> startsWith('abc', 'a')
[1] TRUE
> startsWith('abc', 'c')
[1] FALSE
> endsWith('abc', 'a')
[1] FALSE
> endsWith('abc', 'c')
[1] TRUE
Not inbuilt like that.
Options include grepl
and substr
.
x <- 'ABCDE'
grepl('^AB', x) # starts with AB?
grepl('DE$', x) # ends with DE?
substr(x, 1, 2) == 'AB'
substr('ABCDE', nchar(x)-1, nchar(x)) == 'DE'