strs_slice {strs} | R Documentation |
Slice substrings from a string
Description
strs_slice
extracts substrings from each element of a character vector,
specified by start and stop positions. It is similar to Python's slicing
syntax for strings, but it uses 1 indexing and stops are inclusive.
Usage
strs_slice(string, start = 1L, stop = -1L, ..., step = 1L)
Arguments
string |
A character vector where each element is a string to slice. |
start |
An integerish scalar for the starting position for slicing (inclusive). |
stop |
An integerish scalar for the ending position for slicing (inclusive). |
... |
Used to force keyword argument usage of |
step |
An integer greater than 0 or equal to -1 for the step size. If -1 is provided, each string will be reversed after slicing operations. |
Value
A character vector of the same length as string
, with each element
being the sliced substring.
Examples
strs_slice("hello world", 1, 5)
strs_slice("hello world", 7)
strs_slice("hello world", start = 7, stop = 11)
[Package strs version 0.1.0 Index]