Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^6: substrings that consist of repeating characters

by salva (Canon)
on Sep 30, 2020 at 07:32 UTC ( [id://11122358]=note: print w/replies, xml ) Need Help??


in reply to Re^5: substrings that consist of repeating characters
in thread substrings that consist of repeating characters

Aja, that has allowed me to see the problem!

The (*SKIP) inside the repetition always matches, but once the end of the same-char sequence is reached the \2 fails, so it causes the repetition to backtrack, but it can't because of the (*SKIP), so all the repetition fails!

Moving the (*SKIP) after the \2 fixes the issue:

my $string = "ATTTAGTTCTTAAGGCTGACATCGGTTTACGTCAGCGTTACCCCCCAAGTTTTTTT +TTTTTTTTTTTATTGGGGACTTT"; my $len = 0; my $best = ""; while ($string =~ /((.)(\2(*SKIP)){$len,})/g) { $len = length $1; $best = $1 } print "best: $best\n"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found