fork(1) download
  1. x <- c('qux$foo$bar','qux$foo$bar; input$test$a$a','qux$`foo`; bar$`baz`; x$uvw','qux$`fo o`')
  2. gsub('(\\w*)(?|\\$(\\w+)|\\$`([^`]*)`)', '\\1[["\\2"]]', x, perl=TRUE)
  3.  
Success #stdin #stdout 0.22s 38832KB
stdin
Standard input is empty
stdout
[1] "qux[[\"foo\"]][[\"bar\"]]"                                     
[2] "qux[[\"foo\"]][[\"bar\"]]; input[[\"test\"]][[\"a\"]][[\"a\"]]"
[3] "qux[[\"foo\"]]; bar[[\"baz\"]]; x[[\"uvw\"]]"                  
[4] "qux[[\"fo o\"]]"