On Tue, 4 Oct 2005, [EMAIL PROTECTED] wrote:
On Tue, Oct 04, 2005 at 12:28:20PM -0400, Donald Leslie {74279} wrote:
>> I have a string of the form:
>>
>> 'a bc "d e f" h "i j"' what I want is the quoted items not
>> to split on blanks.
>>
>> [0] = 'a' , [1] = 'bc' , [2] = 'd e f' ... .
>>
>> Is there is simple way to do this ?
>
> Assuming that the quoted strings do not contain escaped quotes:
>
> my $string = 'a bc "d e f" h "i j"';
> my @parts = grep defined $_, $string =~ /\"([^"]*)\"|(\S+)/g;
>
> If the quoted strings do contain escaped quotes, you can still do it, but
> the regex will be more complicated.
Text::Balanced does this, plus a ton more.
Ted
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm