Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by tye (Cardinal)
on Jun 18, 2013 at 21:17 UTC ( #1039665=note: print w/ replies, xml ) Need Help??


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

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        


Comment on Re^5: Finding repeat sequences. (only regex!)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-07-12 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (240 votes), past polls