I have a bunch of strings which look like this:
[3] " 3. Wiki: Los Angeles 3:58pm; score:1.959502"
[4] " 4. Wiki: Boston 6:58pm; score:1.959502"
[5] " 5. Disambiguation: 'Boon; score:1.934644"
[6] " 6. Wiki: The Note (album)\"; score:1.786931"
I parse them into a data frame like this:
read.csv(text=sub("^ [0-9]*\\. (Wiki|Disambiguation): (.*); score:([0-9\\.]*)$","\"\\2\",\\3",ll),
header=FALSE,stringsAsFactors=FALSE)
the trouble is that the \\2 text which I enclose in quotes may contains quotes (double and single) itself.
How do I deal with this?
,"\"\\2\",to,"\'\\2\'help? the sub still workssub("^ [0-9]*\\. (Wiki|Disambiguation): (.*); score:([0-9\\.]*)$","\'\'\'''2''\',\\3", 'hello')