in reply to Re: Re: In need of a stupid regex trick
in thread In need of a stupid regex trick

Oops. (still untested...)

my @list=$str=~/((?<=")[^"]*(?=")|\S+)/g

---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi


Replies are listed 'Best First'.
Re: Re: Re: Re: In need of a stupid regex trick
by CountZero (Bishop) on Jan 05, 2004 at 13:54 UTC
    That doesn't work at all; It gives following results:

    $VAR1 = 'one'; $VAR2 = '"two'; $VAR3 = 'three"'; $VAR4 = ' four five '; $VAR5 = '"six'; $VAR6 = 'seven'; $VAR7 = 'eight"'; $VAR8 = 'nine';

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Yeah, greedy quantifiers bite again. :-(

      my @list=$str=~/((?<=")[^"]*?(?=")|\S+)/g

      Shouldn't that do the trick though? (BTW, im trying to get Perl installed on this box.. I may update once I do)


      ---
      demerphq

        First they ignore you, then they laugh at you, then they fight you, then you win.
        -- Gandhi


        These are the results of the Belgian Jury:
        $VAR1 = 'one'; $VAR2 = '"two'; $VAR3 = 'three"'; $VAR4 = ' four five '; $VAR5 = '"six'; $VAR6 = 'seven'; $VAR7 = 'eight"'; $VAR8 = 'nine';

        It seems your regex is missing the first " and then is off by 1 for all the others.

        Sorry about the bad "Eurovision Song Contest" joke

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law