Hi and thanks in advance for any help
I have a long text ,it contains a lot of info but I am looking to substract a part of it.
the structure of the text and what I need is like this
" requires_shipping = c(TRUE, TRUE), taxable = c(TRUE, TRUE), gift_card = c(FALSE, FALSE), tax_code = c(\"PC040204\", \"PC040204\"\n), name = c(\"Julian Backpack\", \"Mini M.A.C. Crossbody\"), variant_inventory_management = c(\"shopify\", \"shopify\") "
what I am looking for is the items inside the "name" separated by comas so in this case the result would be
"\"Julian Backpack\", \"Mini M.A.C. Crossbody\"
I am using the stringr
package and trying to use the str_subset
or grep
when I use test my regular expression on https://regex101.com/
I use this regex \bname\s[=].+?(?=\))
and I am able to get this match
name = c(\"Julian Backpack\", \"Mini M.A.C. Crossbody\"
but when I try to use it in R I get an error
grep("\bname\s[=].+?(?=\))", string)
Error: '\s' is an unrecognized escape in character string starting ""\bname\s"
Thanks again