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.
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
Mahieux Dimitri wrote:> > 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. >grep("DP2", {other arguments}, fixed=TRUE) ?grep says that "fixed is logical. If TRUE, pattern is a string to be matched as is. Overrides all conflicting arguments." -- View this message in context: http://www.nabble.com/-R--Exact-matching-with-grep-tf3174076.html#a8805966 Sent from the R help mailing list archive at Nabble.com.