Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How do you match a stretch of at least N characters

by hippo (Bishop)
on Sep 11, 2017 at 14:14 UTC ( [id://1199111]=note: print w/replies, xml ) Need Help??


in reply to How do you match a stretch of at least N characters

Let's see here. Your small string has 140 characters and your reference string has 3114. If you were just comparing exactly 10-character substrings that's 131x3105 which is 406755 comparisons. If you then make that >10 character substrings it becomes a lot heavier. eg. for 11, it's 130x3104 which is 403520 to be added on to your original 406755. Build that all the way up to 140 and it comes out as 26,471,170. Then you have the possibility that any one of those characters could be a non-match, so for a substring of length n that's n more matches. That gives a total by my calculations of 1,403,490,770 - and this is just the comparisons, nevermind all the slicing and dicing to achieve them.

Does your task have significant time constraints? If so, you'll have to start looking into some algorithm references to be a lot smarter about this, I fear.

Would I , for instance, start like this? if($reference_str=~/$small_str{10,}/)

No, that would be 10 or more repititions of the entirety of $small_str with 10 or more instances of its last character at the end. (thanks haukex for pointing out my initial error).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found