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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |