in reply to Capture variable length pattern when it repeats variable times

You'll have to benchmark to see if this is more efficient:

my %uniq; my $s = "ABCABCABC1231234123123ABCABCABC123TestTestTestTestTest1234123 +123123121212121212121212121ppppp";; print for grep{ ++$uniq{$_} == 1 } $s =~ m[(?=(.+)\1{4})]g;; Test 1212 2121 12 21 p

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.
  • Comment on Re: Capture variable length pattern when it repeats variable times
  • Download Code

Replies are listed 'Best First'.
Re^2: Capture variable length pattern when it repeats variable times
by exilepanda (Friar) on Apr 02, 2013 at 06:30 UTC
    Work like a charm!! Big Thanks!!

    I added $String .= $String for ( 1..4 ) and run the test. Yours cost 0sec while mine took 6secs. Totally be defeated.

    This also reminds me that mastering regex is really another great topic, though I can read and understand your code, but believe thaz quite far to figure out one like this by myself! Thank you very much again! =)