mercredi 28 janvier 2015

Regular expression to extract inner text in R


Vote count:

0




I got thousands of messages with the following structure



Some header text
-------------------------------------------
text I want to extract
-------------------------------------------
Some footer text


from which I want to extract the "text I want to extract" part and discard anything else. Now I am able to do this in several lines of R code such as



str_locate(messages[i],"-{5,}")


But that amounts to a lot of code. Is there a way to extract the text in a one-liner? In a way that also handles rare cases where the "----"s are not present in a message?



asked 1 min ago







Regular expression to extract inner text in R

Aucun commentaire:

Enregistrer un commentaire