Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by choroba (Cardinal)
on Jun 18, 2013 at 20:23 UTC ( [id://1039653]=note: print w/replies, xml ) Need Help??


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

The .* matches the missing part of the last incomplete repetition.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^6: Finding repeat sequences. (only mostly regex)
by BrowserUk (Patriarch) on Jun 18, 2013 at 20:41 UTC

    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?
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        I am so sorry. You've done the same flip that tye did, capturing the partial rep rather than the complete rep. Threw me completely.

        With a couple of enhancements that works for the 1 rep/1 partial case:

        $s = 'aaaabaaaabaaaaabaaaab';; $s =~ /^((.*).*)\2$/ and print "$1/$2";; aaaabaaaaba/aaaabaaaab

        And still works for that when enhanced to allow for more than 1 complete rep:

        $s =~ /^((.*).*)\1*\2$/ and print "$1/$2";; aaaabaaaaba/aaaabaaaab

        But then fails when given more than one complete rep:

        $s = 'aaaabaaaabaaaaabaaaabaaaaabaaaab';; $s =~ /^((.*).*)\1*\2$/ and print "$1/$2";; aaaabaaaabaaaaabaaaaba/aaaabaaaab

        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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1039653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found