extract_and_substitute: Extract Substring Matching Pattern and Replace

View source: R/extract_properties.R

extract_and_substituteR Documentation

Extract Substring Matching Pattern and Replace

Description

Extract Substring Matching Pattern and Replace

Usage

extract_and_substitute(pattern, replacement, x)

Arguments

pattern

pattern to be matched against the values in x. The pattern may contain pairs of parentheses surrounding parts of the pattern which can be referred to in the replacement string with \1, \2, etc., see example.

replacement

string of the form prop1:value1+prop2:value2+... defining property names and values. In value1, value2, etc. it may be referred to parts of the matching string that correspond to the parts of the pattern enclosed in parentheses, see example.

x

vector of character in which to look for substrings to extract

Examples

kwb.fakin:::extract_and_substitute(
  pattern = "key_(ab(c|d))",
  replacement = "alphabet:true+full:\\1+char2:\\2",
  x = c("noch viel mehr key_abc", "key_abd", "abe")
)

KWB-R/kwb.fakin documentation built on June 14, 2022, 2 p.m.