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
In reply to Re: In need of a stupid regex trick
by Anonymous Monk
in thread In need of a stupid regex trick
by 87C751
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |