[R] perhaps regular expression bug with | sign ??
Henrique Dallazuanna
wwwhsd at gmail.com
Fri Apr 9 22:45:43 CEST 2010
Try this:
sub(x='>|t|',pattern = '\\|t',replacement='zz')
On Fri, Apr 9, 2010 at 5:35 PM, David.Epstein
<David.Epstein at warwick.ac.uk> wrote:
>
> Here is my interaction with R:
>> sub(x='>|t|',pattern = '|t',replacement='zz')
> [1] "zz>|t|"
>
> So I say to myself "Clearly the | signs need to be escaped, so let's try
> this"
>> sub(x='>|t|',pattern = '\|t',replacement='zz')
> [1] "zz>|t|"
> Warning messages:
> 1: '\|' is an unrecognized escape in a character string
> 2: unrecognized escape removed from "\|t"
> How can \| be an unrecognized escape? This flatly contradicts help('regex'),
> or am I misunderstanding the help?
>
> The first pattern above works if one uses extended=F.
>
> What do R experts think?
>
> David
> --
> View this message in context: http://n4.nabble.com/perhaps-regular-expression-bug-with-sign-tp1819872p1819872.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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list