foofoofoo -> Sequence is foo 123456 -> no Sequence ooofoofoofoof -> First sequence is o #### foofoofoofoo -> foo repeated 4 time(s) # correct foofoofoofoo -> foofoo repeated 2 time(s) # wrong #### 123456 -> 123456 #### foo repeated 2 time(s) o f o repeated 3 time(s) #### perl -nle 'printf(defined $3 ? "%s\n" : "%s repeated %s time(s)\n", $1.$3, length($2)/length($1.$3)+1) while/(?:(\w+?)(\1+))|(?:(\w+?)(?!\3))/g' #### __END__ perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web