2016-07-19 16 views
0

いくつかの文字がありますが、典型的なものは次のようなものです。私が欲しいものRの文字変数の特殊文字列を抽出します

{ 
    "body": "Dear Lisa H, \\\n\\\nThank you for staying with us at the Cheshire.We appreciate your feedback and are very happy to hear that you had a wonderful stay. We strive to give the best customer service possible, and are glad that we were consistently able to execute this for you. Thank you for recognizing our staff and we hope that you continue to stay with us in the future. \\\n\\\nSincerely, \\\n\\\nHotel Management", 
    "date": 1337299200, 
    "created_at": 1.3374022991266E9, 
    "_provider": "ThirtyDigits", 
    "author": "Tony Dandino, General Manager at The Cheshire" 
} 

"Thank you for.......future"です。したがって、第2の"\\\n"と第3の"\\\n"の間の言葉です。 Rでそれを行う簡単な方法はありますか?

+1

テキストを字下げしてください。 – akrun

答えて

0
x<-"Dear Lisa H, \\\n\\\nThank you for staying with us at the Cheshire. 
We appreciate your feedback and are very happy to hear that you had 
a wonderful stay. We strive to give the best customer service possible, 
and are glad that we were consistently able to execute this for you. 
Thank you for recognizing our staff and we hope that you continue to 
stay with us in the future. \\\n\\\nSincerely, \\\n\\\nHotel Management" 

gsub("[\\]","",strsplit(x, "\\\n")[[1]][3]) 
関連する問題