http://www.perlmonks.org?node_id=616932


in reply to finding number of contiguous letters

use strict; use warnings; my $str = "computer"; my @parts = $str =~ /(?=(...))/g; print "@parts";

Prints:

com omp mpu put ute ter

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: finding number of contiguous letters
by Marknel (Acolyte) on May 23, 2007 at 05:15 UTC
    thank you.
    I'm trying to understand what the ?= is in the match. off to search perl docs!

      I forgot about some of the fancier Perl RegEx stuff too. ?= is about a third of the way down the page && does positive lookahead. RegExes are so damn wonderfully powerful.

      I'm really enjoying this sweet simple thread. Thanks to all contributors. =)

      Maybe a giant benchmark could be made of every single version. I haven't messed with Benchmark stuff much but it's obviously super-useful too. I'd like to grok it && incorporate it into my Perl practices. Hasta.

      -Pip