[R] How to trim the front of a string?

Gabor Grothendieck ggrothendieck at gmail.com
Sun Nov 22 05:56:39 CET 2009


Here are three ways:

> substring("blackberry", 6)
[1] "berry"
> sub("^black", "", "blackberry")
[1] "berry"
> sub(".{5}", "", "blackberry")
[1] "berry"


On Sat, Nov 21, 2009 at 4:05 PM, rok90 <ivansek.labris at gmail.com> wrote:
>
> Hey everybody!
>
> I have a problem with triming a string. I can get rid of the blank space in
> front and at the back of a string and even trim a string at the back. But I
> don't know how to do it in the front.
>
> For Example: I have a string "Blackberry" and i want to delete the first 5
> characters to get just "berry".
>
> Tnx for your help
> --
> View this message in context: http://old.nabble.com/How-to-trim-the-front-of-a-string--tp26459983p26459983.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list