W
Warren Brown
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?
Back to the odd behavior, the first expression actually returns
[["jkl,"]]. I can't figure out how that is the correct answer by any
reasonable definition of "scan". However, the equivalent String#match
does the same kind of thing, so I must be missing something. Can
someone please explain this behavior?
Thanks,
- Warren Brown
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?
Back to the odd behavior, the first expression actually returns
[["jkl,"]]. I can't figure out how that is the correct answer by any
reasonable definition of "scan". However, the equivalent String#match
does the same kind of thing, so I must be missing something. Can
someone please explain this behavior?
Thanks,
- Warren Brown