Slight tweaks to require space around "quoted string" (which you may or may not want) and remove undef entries. Update: and remove empty entries.
perl -wle'@list = grep defined && length, split /(?:(?<!\S)"([^"]*)"(? +!\S))|\s+/, shift;print for @list' 'one "two three" four "five"'
perl -wle'@list = grep defined, split /(?:(?<!\S)"([^"]*)"(?!\S))|\s+/ +, shift;print for @list' 'one "two three" four "five"'
In reply to Re: Re: Re: In need of a stupid regex trick
by ysth
in thread In need of a stupid regex trick
by 87C751
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |