I'm looking for a regex that decomposes a string containing arguments of a function written in another language in a list of the form argName = value.
An instance of my string of arguments is:
args <- "arg1, arg2 = {{space}}, arg3 = TRUE, arg4 = {{plot, datG1, arg1 = TRUE}}, arg5 = ga, arg6 = {{bla bla {{plot, datG1, arg1 = TRUE}}}}"
where arg1 is an argument without value (by convention, here, value = NA), arg2 takes the value "{{space}}", arg3 takes "TRUE", etc.
Each value should be returned as a string (or NA). The special form {{foo}} is the convention for either a function (as in {{space}}) or a text eventually containing functions (as in {{bla bla {{plot, datG1, arg1 = TRUE}}}}). I already have a code identifying functions and pure text. The only thing I need is to list arguments of each function.
So here, the regex should allow me to decompose the string args in the list
list(
arg1 = NA,
arg2 = "{{space}}",
arg3 = "TRUE",
arg4 = "{{plot, datG1, arg1 = TRUE}}",
arg5 = "ga",
arg6 = "{{bla bla {{plot, datG1, arg1 = TRUE}}}}"
)
The regex I use to identify functions is "\\{\\{((?>[^\\{\\{\\}\\}]+|(?R))*)\\}\\}"