Re: [R] perhaps regular expression bug with | sign ??

2010-04-11 Thread David.Epstein
William Dunlap wrote: 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'), It would

[R] perhaps regular expression bug with | sign ??

2010-04-09 Thread David.Epstein
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

Re: [R] perhaps regular expression bug with | sign ??

2010-04-09 Thread jim holtman
you need to escape it (twice): sub(x='|t|',pattern = '\\|t',replacement='zz') [1] zz| On Fri, Apr 9, 2010 at 4:35 PM, David.Epstein david.epst...@warwick.ac.ukwrote: Here is my interaction with R: sub(x='|t|',pattern = '|t',replacement='zz') [1] zz|t| So I say to myself Clearly the |

Re: [R] perhaps regular expression bug with | sign ??

2010-04-09 Thread Henrique Dallazuanna
Try this: sub(x='|t|',pattern = '\\|t',replacement='zz') On Fri, Apr 9, 2010 at 5:35 PM, David.Epstein david.epst...@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

Re: [R] perhaps regular expression bug with | sign ??

2010-04-09 Thread Phil Spector
David - Here's the last paragraph of the Details section of the regex help page: Patterns are described here as they would be printed by ‘cat’: (_do remember that backslashes need to be doubled when entering R character strings_, e.g. from the keyboard). You can get around this

Re: [R] perhaps regular expression bug with | sign ??

2010-04-09 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David.Epstein Sent: Friday, April 09, 2010 1:36 PM To: r-help@r-project.org Subject: [R] perhaps regular expression bug with | sign ?? Here is my interaction with R: sub(x