简体   繁体   中英

extract special string of character variable in R

I have some characters and a typical one is like the following.

{
    "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"
}

What I want is "Thank you for.......future" . So it's the words between the second "\\\\\\n" and the third "\\\\\\n" . Is there any easier ways to do that in R?

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])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM