in reply to Re: How to get Incremental charecter groups in a string
in thread How to get Incremental charecter groups in a string

It's not clear that 'abbc' is a false positive, and it is not clear that skipping 'is' (as your code does) is appropriate. However the following fixes the supposed false positive and retains the possibly desired 'is':

use strict; use warnings; my $str="this is abc and bcf and xyz and ijklmn but not abbc"; my @words = split ' ', $str; my @incWords = grep { my %uniq = map {$_ => 0} split ''; $_ eq join '', sort keys %uni +q } @words; print "@incWords";

Prints:

is abc bcf xyz ijklmn not

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^3: How to get Incremental charecter groups in a string
by Jasper (Chaplain) on Jun 20, 2006 at 09:03 UTC
    Yes, well, yes, indeed, that does do what you say it does, but who knows what the OP wanted except the OP?

    All I was showing was TMTOWTDI. Maybe. :)

      I did like your trick of turning the regex inside out to check for incrementing runs of letters, but 'bcf' from OP's example argues against that being what is required. Nice trick though. :)


      DWIM is Perl's answer to Gödel