... 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

In reply to Re^5: Regular Expression Translation Help! by AnomalousMonk
in thread Regular Expression Translation Help! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.