What have you tried? What didn't work? We are not a code writing service.

If you need to generate permutations, you can do that pretty easily with glob. That combines with regular expressions pretty easily - have you read perlretut? Also, for your example, I can't get your count of 5 for AAA -- I see either 4 or 6 depending on how you count overlaps.

Update: Stupid failing eyes. I counted two AAAs in the third word.

Node text goes above. Div tags should contain sig only

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

In reply to Re: Regex: finding all possible substrings by kennethk
in thread Regex: finding all possible substrings by ssc11008

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":