RE: splitting strings with quoted white space

2001-06-07 Thread Jeff 'japhy' Pinyan
On Jun 7, Accountant Bob said: >can any one explain to me why this doesn't seem to work: > push @elements, $2 while >/\G\s*(["'])([^\\\1]*(?:\\.[^\\\1]*)*)\1/gc or >/\G(\s*)(\S+)/gc; # k i know that's kinda kloogy, but I'm >experimenting. Let's find out why: friday:~ $ explain \G\s*(

RE: splitting strings with quoted white space

2001-06-07 Thread Accountant Bob
27; Pinyan [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 07, 2001 8:38 AM To: Ondrej Par Cc: Accountant Bob; "Randal L. Schwartz" <[EMAIL PROTECTED]> Peter Cornelius; [EMAIL PROTECTED] Subject: Re: splitting strings with quoted white space On Jun 7, Ondrej Par said: >On Wednesda

Re: splitting strings with quoted white space

2001-06-07 Thread Jeff 'japhy' Pinyan
On Jun 7, Ondrej Par said: >On Wednesday 06 June 2001 22:59, Jeff 'japhy' Pinyan wrote: >> On Jun 6, Accountant Bob said: >> >How about this: (the same but "unrolled") >> > >> >my @elements; >> >push @elements, $1 while >> > /\G\s*"([^\\"]*(?:\\["\\][^\\"]*)*)"/gc or > >I think that > /\

Re: splitting strings with quoted white space

2001-06-07 Thread Ondrej Par
On Wednesday 06 June 2001 22:59, Jeff 'japhy' Pinyan wrote: > On Jun 6, Accountant Bob said: > >How about this: (the same but "unrolled") > > > >my @elements; > >push @elements, $1 while > > /\G\s*"([^\\"]*(?:\\["\\][^\\"]*)*)"/gc or I think that /\G\s*"((?:(?:\\.)|[^\\])*?)"/gc is sh

RE: splitting strings with quoted white space

2001-06-06 Thread Jeff 'japhy' Pinyan
On Jun 6, Accountant Bob said: >How about this: (the same but "unrolled") > >my @elements; >push @elements, $1 while > /\G\s*"([^\\"]*(?:\\["\\][^\\"]*)*)"/gc or > /\G\s*'([^\\']*(?:\\['\\][^\\']*)*)'/gc or > /\G\s*([^\s'"]\S*)/gc; > >is there actually an advantage to doing this? Yes, as i

RE: splitting strings with quoted white space

2001-06-06 Thread Accountant Bob
an advantage to doing this? -Original Message- From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 06, 2001 10:43 AM To: Ondrej Par Cc: Peter Cornelius; [EMAIL PROTECTED] Subject: Re: splitting strings with quoted white space >>>>> "Ondrej" == Ondr

Re: splitting strings with quoted white space

2001-06-06 Thread Randal L. Schwartz
> "Randal" == Randal L Schwartz <[EMAIL PROTECTED]> writes: Randal> my @elements; Randal> push @elements, $1 while Randal> /\G\s*"((?:[^\\"]|\\"|)*)"/gc or Randal> /\G\s*'((?:[^\\']|\\'|)*)'/gc or Randal> /\G\s*([^\s'"]\S*)/gc; Randal> Leaving undefined something like \X as mal

Re: splitting strings with quoted white space

2001-06-06 Thread Randal L. Schwartz
> "Ondrej" == Ondrej Par <[EMAIL PROTECTED]> writes: Ondrej> On Wednesday 06 June 2001 18:19, Randal L. Schwartz wrote: >> That's a good approach, but maybe this one is more straightforward: >> >> $_ = q{whatever "this" 'line is'}; >> >> my @elements; >> push @elements, $1 while >> /\G\s*"(

Re: splitting strings with quoted white space

2001-06-06 Thread Jeff 'japhy' Pinyan
On Jun 6, Randal L. Schwartz said: >> "Jeff" == Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> writes: > >Jeff> On Jun 6, Randal L. Schwartz said: >>> my @elements; >>> push @elements, $1 while >>> /\G\s*"(.*?)"/gc or >>> /\G\s*'(.*?)'/gc or >>> /\G\s*(\S+)/gc; > >Jeff> Randal, would you mind if I u

Re: splitting strings with quoted white space

2001-06-06 Thread M.W. Koskamp
- Original Message - From: Peter Cornelius <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 06, 2001 2:49 AM Subject: splitting strings with quoted white space > I have this script that reads in lines from a configuration file, processes > them, and then stores them in

Re: splitting strings with quoted white space

2001-06-06 Thread Ondrej Par
On Wednesday 06 June 2001 18:19, Randal L. Schwartz wrote: > That's a good approach, but maybe this one is more straightforward: > > $_ = q{whatever "this" 'line is'}; > > my @elements; > push @elements, $1 while > /\G\s*"(.*?)"/gc or > /\G\s*'(.*?)'/gc or > /\G\s*(\S+)/gc; > > print map "<<

Re: splitting strings with quoted white space

2001-06-06 Thread Randal L. Schwartz
> "Jeff" == Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> writes: Jeff> On Jun 6, Randal L. Schwartz said: >> my @elements; >> push @elements, $1 while >> /\G\s*"(.*?)"/gc or >> /\G\s*'(.*?)'/gc or >> /\G\s*(\S+)/gc; Jeff> Randal, would you mind if I used this as an example of \G and /gc in my Jef

Re: splitting strings with quoted white space

2001-06-06 Thread Jeff 'japhy' Pinyan
On Jun 6, Randal L. Schwartz said: >my @elements; >push @elements, $1 while > /\G\s*"(.*?)"/gc or > /\G\s*'(.*?)'/gc or > /\G\s*(\S+)/gc; Randal, would you mind if I used this as an example of \G and /gc in my regex book? Due credit would be given, of course. -- Jeff "japhy" Pinyan [E

Re: splitting strings with quoted white space

2001-06-06 Thread Randal L. Schwartz
> "Ondrej" == Ondrej Par <[EMAIL PROTECTED]> writes: Ondrej> my $line = 'whatever "this" \'line is\''; Ondrej> $line =~ s/\s*$//; Ondrej> my @parts; Ondrej> while ($line ne '') { Ondrej> if ($line =~ m/^\s*(['"])((?:(?:\\.)|[^\\])*?)\1(.*)/) { Ondrej> push @parts, $2

Re: splitting strings with quoted white space

2001-06-06 Thread Ondrej Par
Hi, I'm not sure that I got it right, but let's try: considering you want to parse several substrings from the line, each of them can be either bareword (== sequence of non-whitespace characters) or a quoted strings: my $line = 'whatever "this" \'line is\''; $line =~ s/\s*$//; my @parts; wh

Re: splitting strings with quoted white space

2001-06-06 Thread Chas Owens
On 05 Jun 2001 17:49:53 -0700, Peter Cornelius wrote: > > local $_ = 'name = "quoted string with space"'; > If your pattern always looks like this then try: #!/usr/bin/perl use strict;#make me behave my $name; #holds the key part of config my $value; #the value of par