http://www.perlmonks.org?node_id=948423


in reply to Re: Perl Regex Repeating Patterns
in thread Perl Regex Repeating Patterns

Thanks for the response. The following regex worked properly. I realize that using a quantifier after a capture group is bad programming practice, but I do not know how else to do what I want

my $string="AAABBBCCCCDDDEEEFFFGGGHHHIII"; my @patterns=('BBB','DDD'); my @index; foreach(@patterns){ while($string=~m/\G([A-Z]{3})+?$_/g){ push(@index,$-[2]); pos($string)=$-[2]; }
If there is a better way to do this, please let me know. Thanks.