|Perl Monk, Perl Meditation|
Re: self limiting regex helpby ferrency (Deacon)
|on May 22, 2002 at 15:23 UTC||Need Help??|
If your string is allowed to be empty, try this:
If not, try this:
(Warning, neither was tested)
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 :)