in reply to find all repeating sequences

I believe you want: a) the match and also b) the position of the match? Modifying kschwab's regex..
#!/usr/bin/perl use strict; use warnings; my $string = 'AAAA TTT GGGG CCCC AAAAAA CCCC ABAB CCC TTT TTTT GGGEGEE +'; while ($string =~m/\b((\w)\2{2,6})\b/g) { print "$-[1] $1 \n"; } __END__ #prints 0 AAAA 5 TTT 9 GGGG 14 CCCC 19 AAAAAA 26 CCCC 36 CCC 40 TTT 44 TTTT
Perlvar mentions @- and @+ although the explanation there is not completely clear.
In Perl 5.6.0 the "@-" and "@+" dynamic arrays were introduced that supply the indices of successful matches. @- is the beginning and @+ is the ending. $-[0] and $+[0] correspond to entire pattern, while $-[N] and $+[N] correspond to the $N ($1, $2, etc.) submatches.

Replies are listed 'Best First'.
Re^2: find all repeating sequences
by talexb (Chancellor) on Dec 20, 2016 at 21:01 UTC

    Wow. I never knew about @- and @+ .. that's really quite brilliant. Thanks!!!!

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re^2: find all repeating sequences
by charm (Initiate) on Dec 21, 2016 at 09:04 UTC
    Thank you! This is exactly what I needed