indexOf: Find occurences of string within another string

View source: R/utils_string.R

indexOfR Documentation

Find occurences of string within another string

Description

Returns a vector of the indices where a string occurs in another string

Usage

indexOf(a, b, ignore.case = FALSE)

Arguments

a

string to be checked against

b

string to check

ignore.case

logical; if TRUE, case is ignored when performing the check

Details

If b is longer than a, indexOf returns NA, since it is not possible for a longer string to occur in a shorter string.

Value

Indices where b occurs in a. Returns NA if there are no occurences.

Author(s)

Samuel Leung

See Also

stringr::str_locate_all()

Examples

indexOf("derek", "e")
indexOf("Animals", "a")
indexOf("Animals", "A")
indexOf("Animals", "a", ignore.case = TRUE)

TalhoukLab/biostatUtil documentation built on April 14, 2025, 4:15 a.m.