Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Finding repeat sequences. (only mostly regex)

by choroba (Abbot)
on Jun 18, 2013 at 20:10 UTC ( #1039648=note: print w/ replies, xml ) Need Help??


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

Cannot you find the incomplete repetition with

/^(.*).*\1$/
?

If it is complete, you get the whole one.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re^3: Finding repeat sequences. (only mostly regex)
Download Code
Re^4: Finding repeat sequences. (only mostly regex)
by BrowserUk (Pope) on Jun 18, 2013 at 20:18 UTC

    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.
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1039648]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-12-25 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls