[R] Matching a period in grep...
Alec.Zwart at csiro.au
Alec.Zwart at csiro.au
Wed Aug 6 03:55:52 CEST 2008
Hi folks,
Can anyone enlighten me as to why I get the following when I search for
".csv" at the end of a string?
> grep("\.csv$","Blah.csv",value=TRUE)
[1] "Blah.csv"
Warning messages:
1: '\.' is an unrecognized escape in a character string
2: unrecognized escape removed from "[\.]csv$"
R reference for regular expressions says
"Any metacharacter with special meaning may be quoted by preceding it
with a backslash. [...] The metacharacters in EREs are . \ | ( ) [ { ^
$ * + ?"
Am I missing something here? If "\." is not the right way to match a
period, can anyone tell me what is? I can't find anything on this in R
reference...
I'm using R 2.6 on Windows XP
Thanks,
Alec Zwart
CMIS CSIRO
alec.zwart at csiro.au
More information about the R-help
mailing list