A couple of previous responses seemed to interpret your requirements as looking for anything that is not white space that appears after your 'Query=' but that is not how I read it. An alphanumeric character means that you only want alphabetical and/or numeric characters. A pipe '|' doesn't fit that rule.

perl -ne 'if(m/Query\=\s+(\S+)/){print $1};' monks1085293.data sp|P30443|1A01_HUMAN
Pipes...
perl -ne 'if(m/Query\=\s+([^\s]+)/){print $1};' monks1085293.data sp|P30443|1A01_HUMAN
Pipes...
perl -ne 'if(m/(?:Query\=|\>)\s?([A-Za-z0-9]+)/){print qq|$1\t|};' mon +ks1085293.data sp tr tr

Now this selects exactly what you are looking for...alphanumeric characters that follow either 'Query=' or '>'.

Celebrate Intellectual Diversity


In reply to Re: Help with regex by InfiniteSilence
in thread Help with regex by rocketperl

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.