On Mon, 15 Jan 2001, Thomas, Timothy B wrote:

> Same problem, here's the output I am getting with your new regular
> expression:

> my ($cmd);
> ($cmd) = $command=~/^(\S*)\s/;
> return $cmd;

How about this:

        my $command_with_args;

        my $match_nonspace_expect_in_quotes = qr/((?:"[^"]+"|[^ "]+)+)/;
        
        $command_with_args =~ /$match_nonspace_expect_in_quotes/;

        my $command_part = $1;

        $command_part =~ s/"//g;  # Remove quotes

        return $command_part;

#
#  This works with examples like
#       '"C:\Program Files\"com"mand".exe "%1"';
#

   - Eric B.

--
"An intelligent carrot!  It boggles the mind."


Reply via email to