[R] using perl regular expression
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Feb 24 14:22:21 CET 2009
Katrine Damgaard wrote:
> Hello everybody!
>
> I'm using Perl regular Expression for find pattern in my data set.
>
> The pattern is: NaQxy, where a=E, F, G or H and xy != 29. I have tried this:
>
> pattern <- "^N[E-H]Q[0-9]{2,2}"
> index <- grep(pattern, X, perl=T) #where X is my vector
>
> But the problem is the xy should not be 29. How can I solve this problem.
>
>
pattern = '^N[E-H]Q(?!29)[0-9]{2}'
index = grep(pattern, X, perl=TRUE)
note, an input like NaQ290 will *not* match; you may need to further
specify the pattern.
vQ
More information about the R-help
mailing list