R regular expression: isolate a string between quotes
问题 I have a string myFunction(arg1=\"hop\",arg2=TRUE) . I want to isolate what is in between quotes ( \"hop\" in this example) I have tried so far with no success: gsub(pattern="(myFunction)(\\({1}))(.*)(\\\"{1}.*\\\"{1})(.*)(\\){1})",replacement="//4",x="myFunction(arg1=\"hop\",arg2=TRUE)") Any help by a regex guru would be welcome! 回答1: You could use regmatches function also. Sub or gsub only works for a particular input , for general case you must do grabing instead of removing. > x <-