From: "Hal E. Fulton" Date: 2002-09-20T10:21:16+09:00 Subject: Re: Thoughts on improving usage of Regexp#match ----- Original Message ----- From: "Yukihiro Matsumoto" To: "ruby-talk ML" Sent: Thursday, September 19, 2002 8:07 PM Subject: Re: Thoughts on improving usage of Regexp#match > Hi, > > In message "Re: Thoughts on improving usage of Regexp#match" > on 02/09/20, Dossy writes: > > |a = /x/.match("abc") && $~[1] || "" # a => "" > | > |b = /(b)/.match("abc") && $~[1] || "" # b => "b" > | > |c = /b/.match("abc") && $~[1] || "" # c => "" > > I guess Hal dislikes these for ugly "$". True. And also because they have three operands rather than just two, which crosses my complexity threshold for this kind of situation. :) > Another solution: > > regex.match(str) > sub1 = Regexp.last_match(1) || "" Also good! This will work with 1.6, and it meets all three of my silly criteria. Thanks, Hal