Re: [R] grep with "|" character

2007-10-23 Thread Prof Brian Ripley
Easier is grep("|", stringvector, extended = FALSE) The only reason for having basic regexps in R is to avoid some of the escaping needed. On Tue, 23 Oct 2007, Duncan Murdoch wrote: > On 23/10/2007 6:34 AM, Daniel Brewer wrote: >> Hi, >> >> I am having a problem searching for the "|" character

Re: [R] grep with "|" character

2007-10-23 Thread Duncan Murdoch
On 23/10/2007 6:34 AM, Daniel Brewer wrote: > Hi, > > I am having a problem searching for the "|" character in a string. > >> grep("|",stringvector) > Gives all the strings in a vector but when I try to escape it >> grep("\|",stringvector) > It comes up with the error > Warning messages: > 1: '\|

[R] grep with "|" character

2007-10-23 Thread Daniel Brewer
Hi, I am having a problem searching for the "|" character in a string. > grep("|",stringvector) Gives all the strings in a vector but when I try to escape it > grep("\|",stringvector) It comes up with the error Warning messages: 1: '\|' is an unrecognized escape in a character string 2: unrecogni