Rather than thinking in terms of "splitting on spaces", may be it would work better if you thought in terms of "gather the things I want". For instance, would this work for you:
?#!/usr/bin/perl use strict; use warnings; my $string = q(hi my name is 'john doe'); my @parts = $string =~ /'.*?'|\S+/g; print map { "$_\n" } @parts; __END__
In reply to Re: regex to split on ' ', but skip spaces inside quotes
by duff
in thread regex to split on ' ', but skip spaces inside quotes
by true_atlantis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |