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

______________________________________________
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