From: Simon Strandgaard Date: 2006-12-21T08:46:40+09:00 Subject: Re: Regex question: this should be easy but doesn't work as I expect. On 12/20/06, Sam Kong wrote: [snip] > "one two three four five" #=> [["one", "three", "five']] > "one two four five" #=> [["one", nil, "five']] [snip] how about? irb(main):001:0> r = /(one) (?: (.*?three) | ((?:.(?!>three))*) ) *? (five)/x => /(one) (?: (.*?three) | ((?:.(?!>three))*) ) *? (five)/x irb(main):002:0> "one two three four five".scan(r) => [["one", " two three", " four ", "five"]] irb(main):003:0> "one two four five".scan(r) => [["one", nil, " two four ", "five"]] -- Simon Strandgaard http://opcoders.com/