Sam Kong wrote: > What I want is > > "one two three four five" #=> [["one", "three", "five']] > "one two four five" #=> [["one", nil, "five']] > > In short, in the string, "three" might or might not exist. > What regex can match for both? /one|three|five/ can. Although, its result is not exactly in the form you want: >> "one two three four five".scan /one|three|five/ => ["one", "three", "five"] >> "one two four five".scan /one|three|five/ => ["one", "five"] -- Posted via http://www.ruby-forum.com/.