Skip to content
Prev 255677 / 398506 Next

replace last 3 characters of string

Thx
I could imagine it was so simple.:)
Bert

 
-----Original Message-----
From: Dirk Eddelbuettel [mailto:edd at master.debian.org] On Behalf Of Dirk
Eddelbuettel
Sent: 04 April 2011 01:39
To: Bert Jacobs
Cc: r-help at r-project.org
Subject: Re: [R] replace last 3 characters of string
On Mon, Apr 04, 2011 at 01:39:34AM +0200, Bert Jacobs wrote:
certain
Keep reading up on regular expressions, this tends to pay off. Here we
use the fact that you can achor a regexp to the end of a string:

R> aString <- "abc:def:::"
R> gsub(":::$", "", aString)
[1] "abc:def"
R> 

Hth, Dirk