in reply to Re^4: Finding repeat sequences. (only regex)
in thread Finding repeat sequences.
I think I had \1 and \2 backward. Then you just have to disallow the trivial solution:
$s = 'aaaabaaaabaaaaabaaaab'; $s =~ /^((.*?).*?)(?=.)\1*\2$/ and print "$2/$1";
(Update: Dropped the unneeded () around \1 that I had introduced while debugging. You probably also need to change .*? to .* so you get the longest solution not the shortest.)
- tye
|
---|
In Section
Seekers of Perl Wisdom