I want to extract specific parts of a text string. This works fine, but I also want to extract information based on parentheses ({). However, this does not work for me. R gives me an error (see below).
How can I work with parentheses in string extract? i.e. from the string provided in my example '{ "abc,defghij'
, how would I be able to extract everything between '{ "
and ,
?
textstring <- '{ "abc,defghij'
library(tidyverse)
#Extract everthing between a and f. Desired outcome: bc,de Works fine
textstring <- textstring %>% str_extract('(?<=a).*(?=f)')
#Extract everything between { " and , Desired outcome: abc Doens't work
textstring <- textstring %>% str_extract('(?<={ ").*(?=,)')
#Error in stri_extract_first_regex(string, pattern, opts_regex = opts(pattern)) :
#Syntax error in regexp pattern. (U_REGEX_RULE_SYNTAX)