Try
sub('[^\"]+\"([^\"]+).*', '\\1', x)
or
sub('[^\"]+(\"[^\"]+.).*', '\\1', x)
\"not required since "it will work too
sub('[^"]*("[^"]*.).*', '\\1', x)
, @AvinashRaj, sub . , stringi,
library(stringi)
stri_extract_all_regex(x1, '"[^"]*"')[[1]]
#[1] "\"hop\"" "\"hop2\""
x <- "myFunction(arg1=\"hop\",arg2=TRUE)"
x1 <- "myFunction(arg1=\"hop\",arg2=TRUE arg3=\"hop2\", arg4=TRUE)"