[R] Cannot use an escape character in regexp

Vittorio vdemart1 at tin.it
Fri May 11 13:07:33 CEST 2007


Given the string

> mystr <- "(Preconsuntivo  del  giorno gas 10 maggio 
2007)Tj"

I'm trying to detect and eliminate the string ")Tj" at the 
very end of mystr by means of 
gsub(rx2,"",mystr) BUT preparing the 
matching regexp string a warning pops up

> rx2 <- "\)Tj$"
Warning 
messages:
1: '\)' is an unrecognized escape in a character string 
2: 
unrecognized escape removed from "\)Tj$" 

and

> rx2
[1] ")Tj$"

I 
tried also rx2 <- "(\))Tj$" but the result is the same.

What am I 
missing?

Ciao
Vittorio



More information about the R-help mailing list