50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

strs (version 0.1.0)

strs_rfind: Find the last occurrence of a substring in a string

Description

strs_rfind locates the last occurrence of a specified substring within each element of a character vector. It is similar to Python's str.rfind() method.

Usage

strs_rfind(string, substring)

Value

An integer vector of the same length as string, with each element representing the starting position of the last occurrence of substring in the corresponding element of string. If the substring is not found, the function returns NA for that element.

Arguments

string

A character vector where each element is a string to search.

substring

The substring to find within each element of string.

See Also

Examples

Run this code
strs_rfind("hello world", "o")
strs_rfind("hello world", "x") # not found

Run the code above in your browser using DataLab