strs_find {strs} | R Documentation |
Find the first occurrence of a substring in a string
Description
strs_find
locates the first occurrence of a specified substring within each
element of a character vector. This function is analogous to Python's
str.find()
method.
Usage
strs_find(string, substring)
Arguments
string |
A character vector where each element is a string to search. |
substring |
The substring to find within each element of |
Value
An integer vector of the same length as string
, with each element
representing the starting position of the first occurrence of substring
in
the corresponding element of string
. If the substring is not found, the
function returns NA for that element.
See Also
Python str.find() documentation
Examples
strs_find("hello world", "world")
strs_find("hello world", "x")
[Package strs version 0.1.0 Index]