Skip to contents

Remove Parenthesized Substring

Usage

remove_between_paren(
  x,
  left = "\\(",
  right = "\\)",
  contents_pattern = ".*"
)

Arguments

x

Character vector

left

Left parenthetical string

right

Right parenthetical string

contents_pattern

Regex pattern for the contents between parentheses

Value

Version of x with first parenthesized substrings removed

Examples

x = c("-", "", NA, "1", "3", "1 (Alta.)", "(Sask) 20")
remove_between_paren(x)
#> [1] "-"   ""    NA    "1"   "3"   "1 "  " 20"