easyp3cut: splits an expression into non nested blocks

Description Usage Arguments Details Value Examples

View source: R/f0.rbsb1.code.r

Description

x must be a character string which is parsed to extracts n types of blocks where n is nrow(pth)+1. Something in between pth[i,1] and pth[i,2] is coded i, everything else is coded 0. See the examples.

Usage

1
easyp3cut(x, pth=matrix(c("(", "{", "[", ")", "}", "]"), 3))

Arguments

x

character string to split; must be of length one.

pth

character matrix with two columns defining the opening parentheses in the first column and the closing parentheses in the second column.

Details

The braces can contain more than one character, they must be distinct. Be aware that no check is done about the possible nesting of the parentheses.

Value

A list of two equal length vectors:

\$blo

The vector of character strings (braces are taken off)

\$typ

Corresponding codes of the blocks and 0 when outside of any defined block.

Examples

1
2
3
 rbsb3k("RESET"); # for R checking compliance (useless)
 easyp3cut("(a+b)^[2]");
 easyp3cut("abs({{*Y*}})*{{A}}^{{B}}", matrix(c("{{", "}}"), 1));

rbsb documentation built on May 2, 2019, 4:41 p.m.

Related to easyp3cut in rbsb...