Skip to contents

Extract substrings

Usage

str_sub(string, start = 1L, end = -1L)

Arguments

string

Character vector of strings.

start, end

Integer vectors specifying start and end positions (inclusive). Negative values count backwards from the right hand side; -1 refers to the last character.

Instead of separate start and end parameters you can alternatively provide a two-column matrix (i.e. from str_locate()); the first column will be used for the starting position and the second for the ending position.