unglue_regex.Rd
Transforms a vector of patterns given in the unglue format to a vector of proper regex (PCRE) patterns (so they can for instance be used with functions from other packages).
unglue_regex(
patterns,
open = "{",
close = "}",
use_multiple = FALSE,
named_capture = FALSE,
attributes = FALSE
)
a character vector or a list of character vectors, if a list,
items will be pasted using an empty separator (""
).
The opening delimiter.
The closing delimiter.
whether we should consider that duplicate labels can match different substrings.
whether to incorporate the names of the groups in the output regex
whether to give group attributes to the output
a character vector.
patterns <- c("{number=\\d+} is [{what}]", "{word=\\D+} is [{what}]")
unglue_regex(patterns)
#> {number=\\d+} is [{what}] {word=\\D+} is [{what}]
#> "^(\\d+) is \\[(.*?)\\]$" "^(\\D+) is \\[(.*?)\\]$"