[R] perhaps regular expression bug with | sign ??
David.Epstein
David.Epstein at warwick.ac.uk
Sun Apr 11 23:15:22 CEST 2010
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 be a bit clearer if the warnings indicated that
> they were from the R parser (the function that converts
> your text input to R expressions which are later evaluated).
> The parser is trying to say that it is treating "\|" as "|".
> The backlash has special meaning in things like "\n" (newline),
> "\t" (tab), and "\123" (character number in octal), but not
> before a vertical bar.
>
What is the procedure for requesting an enhancement to code in the base
package? I would like to see the error message changed to something a bit
less puzzling to non-experts. "'\|' is not permitted in a character string.
Did you mean '\\|' or '|'? "
--
View this message in context: http://n4.nabble.com/perhaps-regular-expression-bug-with-sign-tp1819872p1836437.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list