unglue_regex: Converts unglue pattern to regular regex pattern

View source: R/unglue_regex.R

unglue_regexR Documentation

Converts unglue pattern to regular regex pattern

Description

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).

Usage

unglue_regex(
  patterns,
  open = "{",
  close = "}",
  use_multiple = FALSE,
  named_capture = FALSE,
  attributes = FALSE
)

Arguments

patterns

a character vector or a list of character vectors, if a list, items will be pasted using an empty separator ("").

open

The opening delimiter.

close

The closing delimiter.

use_multiple

whether we should consider that duplicate labels can match different substrings.

named_capture

whether to incorporate the names of the groups in the output regex

attributes

whether to give group attributes to the output

Value

a character vector.

Examples

patterns <- c("{number=\\d+} is [{what}]", "{word=\\D+} is [{what}]")
unglue_regex(patterns)

moodymudskipper/unglue documentation built on Sept. 18, 2024, 6:42 p.m.