in reply to Re^4: Regular Expression Translation Help!
in thread Regular Expression Translation Help!
... if something else is not ... Otherwise it will grab ... no?
Why not try it and see?
>perl -wMstrict -le "while (<>) { chomp(my $acc = $_); my $ternary = ($acc =~ /(^USA|^BRA|^CAN)?(.*?)(IN)?$/i) ? $2 : $acc; my $capture2 = defined($2) ? $2 : 'undefined'; print qq{input: '$acc'}; print qq{ternary: '$ternary' \\2: '$capture2'}; } " USA1111 input: 'USA1111' ternary: '1111' \2: '1111' BRA1111 input: 'BRA1111' ternary: '1111' \2: '1111' xxxUSA1111 input: 'xxxUSA1111' ternary: 'xxxUSA1111' \2: 'xxxUSA1111' foo input: 'foo' ternary: 'foo' \2: 'foo' ^Z
|
|---|