This was a bug which is already fixed in R-2.0.1 patched. From the NEWS
file
o gsub(perl=TRUE) returned a string which printed with trailing
garbage if there was a match at the beginning whose
replacement was shorter. (PR#7479)
The crucial comment is that it only happened
I have a problem doing substitution using sub and perl=TRUE when the
elements of x have fewer characters than the replacement string. Let me
show you what I mean:
sub(m,billy,m)
[1] billy
But using perl=TRUE, I can only return a result as long as my x:
sub(m,billy,m,perl=TRUE)
[1] b