Skip to content

grep : escape "*"

7 messages · Henrique Dallazuanna, Duncan Murdoch, Gábor Csárdi +3 more

#
On 1/9/2009 10:38 AM, David Hajage wrote:
You use a backslash to escape the *.  Unfortunately, to enter a 
backslash in an R string, you need to escape it.  So the pattern is "\\*".

Duncan Murdoch
#
* must be escaped for grep with \ and \ must be escaped for R itself
with another \, so you need

grep("\\*", c("/3", "2*3", "4-4"))

Gabor

2009/1/9 David Hajage <dhajage.r at gmail.com>:

  
    
#
Use fixed = TRUE argument to grep.

2009/1/9 David Hajage <dhajage.r at gmail.com>:
#
Hi there, you probably want something like:

# R
grep("\\*", c("/3", "2*3", "4-4"))


hope that helps a little,
Tony Breyal
On 9 Jan, 15:38, "David Hajage" <dhajag... at gmail.com> wrote: