make_or_pattern {RCLabels}R Documentation

Create "or" regex patterns

Description

This function makes "or" regex patterns from vectors or lists of strings. This function can be used with the matsbyname::select_rows_byname() and matsbyname::select_cols_byname functions. make_or_pattern() correctly escapes special characters in strings, such as ( and ⁠)⁠, as needed. Thus, it is highly recommended that make_or_pattern be used when constructing patterns for row and column selections with matsbyname::select_rows_byname() and matsbyname::select_cols_byname().

Usage

make_or_pattern(
  strings,
  pattern_type = c("exact", "leading", "trailing", "anywhere", "literal")
)

Arguments

strings

A vector of row and column names.

pattern_type

One of "exact", "leading", "trailing", "anywhere", or "literal". Default is "exact".

Details

pattern_type controls the type of pattern created:

Value

An "or" regex pattern suitable for selecting row and column names. Amenable for use with matsbyname::select_rows_byname or matsbyname::select_cols_byname.

Examples

make_or_pattern(strings = c("a", "b"), pattern_type = "exact")
make_or_pattern(strings = c("a", "b"), pattern_type = "leading")
make_or_pattern(strings = c("a", "b"), pattern_type = "trailing")
make_or_pattern(strings = c("a", "b"), pattern_type = "anywhere")
make_or_pattern(strings = c("a", "b"), pattern_type = "literal")

[Package RCLabels version 0.1.10 Index]