in reply to Question on conditional regular expressions/backreferences
If the number of possible outcomes is small, you can just construct an alternation manually:
If you have larger sets of alternations, your best bet is to assemble the alternatives with a program (perl 5.10 has very good optimizations for larger sets of constant alternatives), or to use assertions like this:/ACATGT|GCATGC/
our %map = ( A => 'T', C => 'C' ); /([AC])CATC(??{$map{$1})/
(Untested). But if you do the latter, please read the warnings in perlre first, (??{...}) is an experimental feature.
This one captures the result from the [AC] in the variable $1 and then matches against a transformed version of that.
|
|---|