in reply to Re^2: Regular expression problems
in thread Regular expression problems

You can want to add 'M' and '_' in parens to capture in one shot or concatanate 'M'.$1.'_' depending of what you want to do. One way to do it:
#!/usr/bin/perl -w use strict; my $seqnum=1; while (my $seq=<DATA>) { chomp $seq; print "sequence #",$seqnum++,":\n"; while ($seq =~ /M([GAVLIFWPSTCYNQDEKRH]+)_/g) { print "\t",$1,"\n"; # or: print "\t","M${1}_","\n"; } } __DATA__ MHGRRRRRRRRRRRRRRRRRRRRRRRRRRRRRD_MHGRRRRRRRRD_ CMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVTECMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVT AWPPPPPPPPPPPPPPPPPPPPPPPPPPPPP_LNAWPPPPPPPPPPPPPPPPPPPPPPPPPPPPP_L FOOBARMNOTTHISONE_XYZMTHISYES_MTHISNOT_