Odd behavior of String#scan

I don't think it's possible without lookbehind assertions. Maybe
Oniguruma supports this.

Regards,

Dan

···

-----Original Message-----
From: Bob Showalter [mailto:bob_showalter@taylorwhite.com]
Sent: Wednesday, December 21, 2005 2:49 PM
To: ruby-talk ML
Subject: Re: Odd behavior of String#scan

Warren Brown wrote:
> First off, the problem I am trying to solve can be
simplified down
> to:
>
> 'abcSTARTdef,ghi,jkl,ENDmno'.scan(/START([^,]*,)*END/)
>
> What I want is [["def,"], ["ghi,"], ["jkl,"]] (or the
same thing
> without the commas), and I still need a way to achieve this. I can
> accomplish it with:
>
> 'abcSTARTdef,ghi,jkl,ENDmno'.scan(/START(.*)END/)[0][0].split(/,/)
>
> But this does two operations where it seems like one should
> suffice. Does someone know of a way to do this in a single
operation?

I would suggest:

   'abcSTARTdef,ghi,jkl,ENDmno'.match(/START(.*)END/)[1].split(',')

I don't know of a way to accomplish it in one step.