strs_startswith: Check if string starts with a specified prefix

View source: R/startswith.R

strs_startswithR Documentation

Check if string starts with a specified prefix

Description

strs_startswith determines whether each element of a character vector starts with a specified prefix. It is similar to Python's str.startswith() method.

Usage

strs_startswith(string, prefix)

Arguments

string

A character vector where each element is a string to be checked.

prefix

The prefix to check for at the start of each element of string.

Value

A logical vector of the same length as string, with each element indicating whether the corresponding element of string starts with prefix.

See Also

Python str.startswith() documentation

Examples

strs_startswith("hello world", "hello")
strs_startswith(c("test", "hello", "world"), "te")

strs documentation built on Sept. 11, 2024, 6:44 p.m.