unglue_regex: Converts unglue pattern to regular regex pattern

Description Usage Arguments Value Examples

View source: R/unglue_regex.R

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

1
2
3
4
5
6
7
8
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

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

unglue documentation built on July 1, 2020, 5:46 p.m.