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...@gmail.com> wrote:
> Dear R useRs,
>
> Sorry for this foolish question, but I can't find how to escape the *
> character when using grep :
>
> > grep("-", c("/3", "2*3", "4-4"))
> [1] 3
> > grep("/", c("/3", "2*3", "4-4"))
> [1] 1
> > grep("*", c("/3", "2*3", "4-4"))
>
> Erreur dans grep("*", c("/3", "2*3", "4-4")) :
>   expression régulière incorrecte '*'
> De plus : Warning message:
> In grep("*", c("/3", "2*3", "4-4")) :
>   erreur rgcomp : 'Expression régulière précédente incorrecte'> grep("\*", 
> c("/3", "2*3", "4-4"))
>
> Erreur dans grep("*", c("/3", "2*3", "4-4")) :
>   expression régulière incorrecte '*'
> De plus : Warning messages:
> 1: '\*' est un code escape non reconnu dans une chaîne de caractères
> 2: code escape non reconnu éliminé de "\*"
> 3: In grep("*", c("/3", "2*3", "4-4")) :
>   erreur rgcomp : 'Expression régulière précédente incorrecte'
>
> Best regards,
>
> david
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@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.

Reply via email to