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 reply to Re^5: Finding repeat sequences. (only regex!)
by tye
in thread Finding repeat sequences.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |