grapes-ends_with-grapes: check whether a character string ends with a string

%ends_with%R Documentation

check whether a character string ends with a string

Description

Escapes any special RegExp characters in the search term. A way to check whether the search term (e.g. a variable name) is the ending. Just a simple shorthand so that inexperienced R users don't have to use somewhat complex functions such as grepl() and stringr::str_detect().

Usage

haystack %ends_with% needle

Arguments

haystack

string in which you search

needle

string to search for

Examples

"1, 3, 4" %ends_with% "4" # TRUE
"1, 3, 4" %ends_with% 4 # unlike str_detect casts all needles as characters
"1, 3, 4" %ends_with% "." # FALSE

rubenarslan/formr documentation built on Feb. 6, 2024, 1:18 a.m.