in reply to experimental regex (?(?{code}) conditional (??{ 'code' }) )
#!/usr/bin/perl -w use strict; for ( '<1>', # want match '<<2>>', # want match '<<3>', # want fail '<<<4>>', # want fail '<<5>>>>', # want fail ) { my $left = tr/<//; my $right = tr/>//; if ($left == $right) { print "$_ match\n"; } else { print "$_ fail\n"; } } __END__ Prints: <1> match <<2>> match <<3> fail <<<4>> fail <<5>>>> fail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: experimental regex (?(?{code}) conditional (??{ 'code' }) )
by Anonymous Monk on Nov 12, 2010 at 16:53 UTC | |
by Marshall (Canon) on Nov 12, 2010 at 17:07 UTC | |
by Anonymous Monk on Nov 12, 2010 at 17:33 UTC |