in reply to Re^7: Finding repeat sequences. (only mostly regex)
in thread Finding repeat sequences.
I am so sorry. You've done the same flip that tye did, capturing the partial rep rather than the complete rep. Threw me completely.
With a couple of enhancements that works for the 1 rep/1 partial case:
$s = 'aaaabaaaabaaaaabaaaab';; $s =~ /^((.*).*)\2$/ and print "$1/$2";; aaaabaaaaba/aaaabaaaab
And still works for that when enhanced to allow for more than 1 complete rep:
$s =~ /^((.*).*)\1*\2$/ and print "$1/$2";; aaaabaaaaba/aaaabaaaab
But then fails when given more than one complete rep:
$s = 'aaaabaaaabaaaaabaaaabaaaaabaaaab';; $s =~ /^((.*).*)\1*\2$/ and print "$1/$2";; aaaabaaaabaaaaabaaaaba/aaaabaaaab
|
|---|