[R] regular expression for nth character in a string

Gonçalo Ferraz gferraz29 at gmail.com
Mon Apr 25 12:17:44 CEST 2011

Hi, I have a string


and want to extract, say, the first two characters: "In"
or the last three: "blee"
or the 3rd, 4th, and 5th: "Trou"

Is there an easy way of doing this quickly with regular expressions in gsub, grep or similar?

Thank you for any help.


More information about the R-help mailing list