From: Mark Hubbart Date: 2004-11-12T04:11:40+09:00 Subject: Re: #scan with or'd (`|`) subexpressions. On Fri, 12 Nov 2004 01:52:00 +0900, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: #scan with or'd (`|`) subexpressions." > on Thu, 11 Nov 2004 23:29:58 +0900, "trans. (T. Onoma)" writes: > > |Does the new Ruby regexp engine do this? > > > | > | irb(main):001:0> '1234'.scan(/(1)(2)|(3)(4)/) > | => [["1", "2", nil, nil], [nil, nil, "3", "4"]] > | irb(main):002:0> > | > |Why would all the subexpressions be listed when there is an `|` (or) used? I > |expected: > | > | => [["1", "2"], ["3", "4"]] > > You will never know which subexpression is matched, if you get your > expected result. Is there any reason /(1|3)(2|4)/ is not sufficient? This reminds me... when will Ruby support named subexpressions? Oniguruma fully supports them now; but there doesn't appear to be a way to access this in the ruby code. thanks, Mark