match.String: Helper to match string(s).

View source: R/utils.R

match.StringR Documentation

Helper to match string(s).

Description

Helper function to return a vector with string(s) matching the pattern(s). The function aims to match each pattern individually (in a loop), and returns an error if one of them has no match.

Usage

match.String(pattern = null, x, value = FALSE)

Arguments

pattern

String or vector with pattern(s) to match.

x

String or vector to search.

value

Boolean to retrieve the value.

Details

The function first attempts an exact match. When there are no exact matches it attempts to match a regular expression. The regular expression aims to match at the end of the input 'x'.

In case of multiple matches on the first result is returned. Depending on the 'value' a value or index is returned.

Value

Vector with column numbers or names.

Examples

match.String(c("A", "b"), c("A", "B", "C")) returns [1] 1 2

n0Trader/TDI documentation built on July 30, 2023, 7:48 p.m.