regex - How to find the largest repeating string with overlap in a line -
I have a series of rows such as my $ string = "home test results Result-apr-25 result-apr-251 csv "; @ Str = $ string = ~ / (\ w +) \ 1 + / i; Print "@ str"; How do I find the biggest repeated string with overlap which separates from white space? In this case I am looking for output: result-apr-25 It looks like you need to calculate the most common substrans. Do not try it Pearl-only twin brother because it has insects. Use strict; Use warnings; String :: Use LCSS_XS; * LCSS = \ and string :: LCSS_XS :: LCSS; #My $ var of `lcss` manually = 'Result results of home test- apr-25 result-apr-251.csv'; My @words = partition '', $ var; My longest; Mine ($ first, $ second); My $ i (0 .. $ # words) {my $ j ($ i + 1 .. $ # word) {my $ lcss = lcss (forwords [$ i, $ j]); Unless ($ longest and length $ lcss & lt; = length $ longest) {$ longest = $ lcss; ($ First, $ sec) = @words [$ i, $ j]; }}} Printf qq {Longest general substring is ...