st_within: Get string between two regular expression patterns

View source: R/helpers.R

st_withinR Documentation

Get string between two regular expression patterns

Description

Returns a substring enclosed by two regular expression patterns. By default returns the name of the arguments being indexed by squared brackets ([]) in a string containing an expression.

Usage

st_within(
  x,
  left = "[^_[:^punct:]]|\\b",
  right = "\\[",
  rm_left = 0,
  rm_right = -1
)

Arguments

x

A character string.

left

A character string. Regular expression to serve as look ahead.

right

A character string. Regular expression to serve as a look behind.

rm_left

An integer. Number of bites after left-side match to remove from result. Defaults to -1.

rm_right

An integer. Number of bites after right-side match to remove from result. Defaults to 0.

Value

A character vector.

Examples

a <- '(XX[Y=0] == 1) > (XX[Y=1] == 0)'
CausalQueries:::st_within(a)
b <- '(XXX[[Y=0]] == 1 + XXX[[Y=1]] == 0)'
CausalQueries:::st_within(b)

CausalQueries documentation built on Oct. 20, 2023, 1:06 a.m.