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

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


Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: In need of a stupid regex trick
by CountZero (Bishop) on Jan 05, 2004 at 22:17 UTC
    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

      I finally got the time to get perl installed and ive worked out what is wrong. It seems that pos isn't updated when the look ahead assertion is matched. So even though the " was matched the next match on /g didnt start _after_ the second quote, but _at_ the second quote. Thus the odd behaviour of treating the second unquoted section as if it were quoted. Or at least thats how I read this. All very interesting. Thanks for the repeated feedback...

      :-)


      ---
      demerphq

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