[R] Exact matching with grep

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Mon Feb 5 13:55:36 CET 2007


Mahieux Dimitri wrote:
> Hello,
>
> I would know if it is possible with grep to match a exact string. For 
> example, I want to match the string "DP2" (and only this) and grep match 
> "DP2BS" too.
> I have sought in the grep help but I didn't find what I want.
>   
"^DP2$" could be what you are looking for, although I wonder why you
didn't just test for equality with == in the first place. Also, word
matching as in "\\<DP2\\>" could be relevant.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list