我有以下字符串:
x<-"\"stream;\"\" Well done; fans !!\"\";\"\"Boy\""
我在R中寻找语法,这使我能够从字符串中提取"Well done; fans !!"
。
感谢您的帮助。
答案 0 :(得分:1)
通过gregexpr
和regmatches
功能。
> x<-"\"stream;\"\" Well done; fans !!\"\";\"\"Boy\""
> m <- gregexpr("\"[^\"]*\"", x)
> o <- regmatches(x, m)
> o[[1]][2]
[1] "\" Well done; fans !!\""
这将匹配所有双引号字符串并仅打印第二个值。