Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

Check if string contains a substring

Source:R/contains.R
strs_contains.Rd

strs_contains checks whether each element of a character vector contains aspecified substring. This function mirrors the functionality of Python'sstr.__contains__() method.

Usage

strs_contains(string,substring)

Arguments

string

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

substring

The substring to search for within each element ofstring.

Value

A logical vector of the same length asstring, with each elementindicating whether the corresponding element ofstring containssubstring.

Examples

strs_contains("hello world","world")#> [1] TRUEstrs_contains(c("apple","banana","cherry"),"a")#> [1]  TRUE  TRUE FALSE

[8]ページ先頭

©2009-2025 Movatter.jp