in reply to Re^3: Help to build a REGEXP (BioPerl)
in thread Help to build a REGEXP

Try m//ms instead if //gs

Also, use re 'debug'; to see how the regex engine matches your string ... you can also use rxrx - command-line REPL and wrapper for Regexp::Debugger

#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; my $line7 = q{ CDS join(2432..2501,5144..5154,57 /translation="MLSFVDTRTLLL" exon 2432..2501 }; my $amino_acid_seq; { use re 'debug'; ($amino_acid_seq ) = $line7 =~ m/^\s+\/translation\=\"(.*?)\"/s; } dd( $amino_acid_seq ); { use re 'debug'; ($amino_acid_seq ) = $line7 =~ m/^\s+\/translation\=\"(.*?)\"/ms; } dd( $amino_acid_seq ); __END__ Compiling REx "^\s+/translation\=\%"(.*?)\%"" Final program: 1: SBOL (2) 2: PLUS (4) 3: SPACE (0) 4: EXACT </translation="> (9) 9: OPEN1 (11) 11: MINMOD (12) 12: STAR (14) 13: SANY (0) 14: CLOSE1 (16) 16: EXACT <"> (18) 18: END (0) floating "/translation=%"" at 1..2147483647 (checking floating) anchor +ed(SBOL) minlen 16 Compiling REx "^\s+/translation\=\%"(.*?)\%"" Final program: 1: MBOL (2) 2: PLUS (4) 3: SPACE (0) 4: EXACT </translation="> (9) 9: OPEN1 (11) 11: MINMOD (12) 12: STAR (14) 13: SANY (0) 14: CLOSE1 (16) 16: EXACT <"> (18) 18: END (0) floating "/translation=%"" at 1..2147483647 (checking floating) anchor +ed(MBOL) minlen 16 Guessing start of match in sv for REx "^\s+/translation\=\%"(.*?)\%"" +against "%nCDS join(2432..2501,5144..5 154,57%n "... Found floating substr "/translation=%"" at offset 68... Guessed: match at offset 0 Matching REx "^\s+/translation\=\%"(.*?)\%"" against "%nCDS + join(2432..2501,5144..5154,57%n "... 0 <> <%nCDS > | 1:SBOL(2) 0 <> <%nCDS > | 2:PLUS(4) SPACE can match 1 times out of 21474 +83647... failed... Match failed undef Guessing start of match in sv for REx "^\s+/translation\=\%"(.*?)\%"" +against "%nCDS join(2432..2501,5144..5 154,57%n "... Found floating substr "/translation=%"" at offset 68... Position at offset 0 does not contradict /^/m... Guessed: match at offset 0 Matching REx "^\s+/translation\=\%"(.*?)\%"" against "%nCDS + join(2432..2501,5144..5154,57%n "... 0 <> <%nCDS > | 1:MBOL(2) 0 <> <%nCDS > | 2:PLUS(4) SPACE can match 1 times out of 21474 +83647... failed... Guessing start of match in sv for REx "^\s+/translation\=\%"(.*?)\%"" +against "CDS join(2432..2501,5144..515 4,57%n "... Found floating substr "/translation=%"" at offset 67... Position at offset 0 does not contradict /^/m... Guessed: match at offset 0 1 <%n> <CDS > | 1:MBOL(2) 1 <%n> <CDS > | 2:PLUS(4) SPACE can match 0 times out of 21474 +83647... failed... Guessing start of match in sv for REx "^\s+/translation\=\%"(.*?)\%"" +against "DS join(2432..2501,5144..5154 ,57%n "... Found floating substr "/translation=%"" at offset 66... Found /^/m at offset 45... Guessed: match at offset 45 47 <4,57%n> < > | 1:MBOL(2) 47 <4,57%n> < > | 2:PLUS(4) SPACE can match 21 times out of 2147 +483647... 68 < > </translati> | 4: EXACT </translation=">(9) 82 <ion="> <MLSFVDTRTL> | 9: OPEN1(11) 82 <ion="> <MLSFVDTRTL> | 11: MINMOD(12) 82 <ion="> <MLSFVDTRTL> | 12: STAR(14) SANY can match 12 times out of 12. +.. 94 <RTLLL> <"%n > | 14: CLOSE1(16) 94 <RTLLL> <"%n > | 16: EXACT <">(18) 95 <TLLL"> <%n > | 18: END(0) Match successful! "MLSFVDTRTLLL" Freeing REx: "^\s+/translation\=\%"(.*?)\%"" Freeing REx: "^\s+/translation\=\%"(.*?)\%""

Also interesting (but tad more pita to install) is wxPPIxregexplain.pl