in reply to self limiting regex help
If not, try this:print "match" if $string =~ /[atcg]*([RYMKSWHBVDN][atcg]*){0,2}/i;
(Warning, neither was tested)print "match" if $string and $string =~ /[atcg]*([RYMKSWHBVDN][atcg]*) +{0,2}/i;
Update:Sorry about that: You're both right, I misunderstood the initial request. The regex above matches up to 2 occurrances of any of the alternate codes, not any number of occurrances of up to 2 of the alternate codes.
You could do what you want with an extremely long regex which enumerates every combination of 2 alternate codes. That's a really bad answer, though: it would be much shorter and more straightforward to do it with regexes supplemented by other perl code.
Sorry for the wrong answer :)
Alan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: self limiting regex help
by spq (Friar) on May 22, 2002 at 15:34 UTC | |
|
Re: Re: self limiting regex help
by dsheroh (Monsignor) on May 22, 2002 at 15:37 UTC |