[Chicago-talk] Regex and the whitespace before it.

Mike Fragassi frag at ripco.com
Wed Mar 26 11:54:11 PDT 2008



On Wed, 26 Mar 2008, Mike Ferrari wrote:

> when i see this..  " my @aa = map {s/\n//g;$_} split /(\w+)\s*:\s*/,
> $string; "
>
> my eyes glaze over.. sort of like Homer Simpson when he sees doughnuts..

Without using map, which is tricky, you could do it like this:

my @aa = split /(\w+)\s*:\s*/, $string;
for (@aa) {
   s/\n//g;
}

It's the same thing, really.

-- Mike F.


More information about the Chicago-talk mailing list