Your second match has no captures and your third only matches lowercase. Regex might not be the best option for parsing this format in a robust fashion. That said:

#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; my $content = join '', <DATA>; $content =~ /LOCUS\s+([A-Z0-9_]+)/; my $locus = $1; $content =~ /(Putative.*?);/s; my $acids = $1; $acids =~ s/\n\s+/ /g; $content =~ /TITLE\s*(.*?)\n\s+JOURNAL/s; my $aminoAcids = $1; $aminoAcids =~ s/\n\s+/ /g; is $locus, 'PPI3_SYNY3'; is $acids, 'Putative thylakoid lumen peptidyl-prolyl cis-trans isomera +se sll0408'; is $aminoAcids, 'Sequence analysis of the genome of the unicellular cy +anobacterium Synechocystis sp. strain PCC6803. II. Sequence determina +tion of the entire genome and assignment of potential protein-coding +regions'; __DATA__ LOCUS PPI3_SYNY3 379 aa linear BCT 1 +3-NOV-2019 DEFINITION RecName: Full=Putative thylakoid lumen peptidyl-prolyl cis +-trans isomerase sll0408; Short=Putative thylakoid lumen PPIase; +AltName: Full=Putative thylakoid lumen rotamase; Flags: Precursor. ACCESSION Q55118 VERSION Q55118.2 REFERENCE 1 (residues 1 to 379) AUTHORS Kaneko,T., Sato,S., Kotani,H., Tanaka,A., Asamizu,E., Naka +mura,Y., Miyajima,N., Hirosawa,M., Sugiura,M., Sasamoto,S., Kimura, +T., Hosouchi,T., Matsuno,A., Muraki,A., Nakazaki,N., Naruo,K., Okumura,S., Shimpo,S., Takeuchi,C., Wada,T., Watanabe,A., Yamada,M., Yasuda,M. and Tabata,S. TITLE Sequence analysis of the genome of the unicellular cyano +bacterium Synechocystis sp. strain PCC6803. II. Sequence determinati +on of the entire genome and assignment of potential protein-coding r +egions JOURNAL DNA Res. 3 (3), 109-136 (1996) PUBMED 8905231 REMARK NUCLEOTIDE SEQUENCE [LARGE SCALE GENOMIC DNA].; STRAIN=PCC 6803 / Kazusa REFERENCE 2 (residues 1 to 379)

In reply to Re: advance Regex by hippo
in thread advance Regex by shabird

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.