http://www.perlmonks.org?node_id=1039651


in reply to Re^3: Finding repeat sequences. (only mostly regex)
in thread Finding repeat sequences.

There are no gaps between the repeats, so the uncaptured .* is not required (actually mustn't be there).

And if the second rep is incomplete \1 will never match before $.

I've been trying variations on

$s = 'aaaabaaaabaaaaabaaaab';; $s =~ m[^(.+)\1*(.*?$)] and $1 =~ $2 and print "$1/$2";; aaaabaaaabaaaaabaaaab/

With the idea that any partial rep at the end can be verified again the beginning of the full rep, but it needs to happen inside the regex and cause backtracking.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^5: Finding repeat sequences. (only mostly regex)
by choroba (Cardinal) on Jun 18, 2013 at 20:23 UTC
    The .* matches the missing part of the last incomplete repetition.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      No. Any incomplete rep will alway be at the end of the string. 'fredf', 'fredfr', 'fredfre', 'fredfredfre' etc.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Right. In fredfr, the ed will be matched by the .* between the repetitions. It corresponds to the missing part of the last repetition. Or am I missing something?
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ