in reply to In need of a stupid regex trick

My own 2c. You may like it if you like that the regex itself does all the work...

my $s = ' one "two three" four five "six seven eight" nine'; my @w = $s =~ / \s* #strip whitespace outside of paren "blocks" (?:"(?{local $openq=1}))? #note fact of open-quote without storing ((??{$openq ? '[^"]*' : '\w+'})) #store block (?:(??{$openq ? '"' : '\b'})) #gobble up closeq or word-boundary(rea +lly nop in this case) /gx; local $" = ':'; print "@w\n";

,welchavw

Replies are listed 'Best First'.
Re: Re: In need of a stupid regex trick
by welchavw (Pilgrim) on Jan 05, 2004 at 21:22 UTC

    uhhh, that AM post there is mine own...so if you'd like to --, then you can hit this node instead!

    ,welchavw