Change to /.../.match("foo") behaviour in 1.6.8?

In 1.6.7 and 1.7, I had the following line work:

  l, m1, m2 = /((?:\S+\s+){11})(.+)/.match(line)

This meant that #match return worked like an array. I was just
running the unit tests on Text::Format (new release coming shortly)
and the values were a MatchData, nil, nil. I’ve fixed this by
explicitly using l[1] and l[2] when I need it, but has this changed,
or did it work by accident previously? (I’m using 1.6.8 mswin32.)

-austin
– Austin Ziegler, austin@halostatue.ca on 2003.03.31 at 08:58:20

Hi –

···

On Mon, 31 Mar 2003, Austin Ziegler wrote:

In 1.6.7 and 1.7, I had the following line work:

  l, m1, m2 = /((?:\S+\s+){11})(.+)/.match(line)

This meant that #match return worked like an array. I was just
running the unit tests on Text::Format (new release coming shortly)
and the values were a MatchData, nil, nil. I’ve fixed this by
explicitly using l[1] and l[2] when I need it, but has this changed,
or did it work by accident previously? (I’m using 1.6.8 mswin32.)

I don’t think that’s changed. Can you give a whole demo of the
different behaviors?

David


David Alan Black
home: dblack@superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

Hi,

···

In message “Change to /…/.match(“foo”) behaviour in 1.6.8?” on 03/03/31, Austin Ziegler austin@halostatue.ca writes:

In 1.6.7 and 1.7, I had the following line work:

 l, m1, m2 = /((?:\S+\s+){11})(.+)/.match(line)

This meant that #match return worked like an array.

Put “*” before the expression, e.g.

l, m1, m2 = */((?:\S+\s+){11})(.+)/.match(line)

						matz.

I don't think that's changed. Can you give a whole demo of the
different behaviors?

pigeon% ./ruby -ve 'a, b = /(.)/.match("ab"); p a,b'
ruby 1.4.6 (2000-08-16) [i686-linux]
"a"
"a"
pigeon%

pigeon% ./ruby -ve 'a, b = /(.)/.match("ab"); p a,b'
ruby 1.6.0 (2000-09-19) [i686-linux]
#<MatchData:0x401adc48>
nil
pigeon%

Guy Decoux

Hi –

Hi,

In 1.6.7 and 1.7, I had the following line work:

 l, m1, m2 = /((?:\S+\s+){11})(.+)/.match(line)

This meant that #match return worked like an array.

Put “*” before the expression, e.g.

l, m1, m2 = */((?:\S+\s+){11})(.+)/.match(line)

I’m getting confused… It looks like 1.8 goes back to the 1.4
behavior – am I right about that?

candle:~$ ruby -ve ‘a, b = /(.)/.match(“ab”); p a,b’
ruby 1.8.0 (2003-03-03) [i686-linux]
“a”
“a”

and for the other behavior, the * doesn’t seem to change it (in this
1.6.8 example):

candle:~$ ruby/1.6.8/bin/ruby -ve ‘a, b = */(.)/.match(“ab”); p a,b’
ruby 1.6.8 (2002-12-24) [i686-linux]
#MatchData:0x401bb98c
nil

David

···

On Tue, 1 Apr 2003, Yukihiro Matsumoto wrote:

In message “Change to /…/.match(“foo”) behaviour in 1.6.8?” > on 03/03/31, Austin Ziegler austin@halostatue.ca writes:


David Alan Black
home: dblack@superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

Hi –

I don’t think that’s changed. Can you give a whole demo of the
different behaviors?

pigeon% ./ruby -ve ‘a, b = /(.)/.match(“ab”); p a,b’
ruby 1.4.6 (2000-08-16) [i686-linux]
“a”
“a”
pigeon%

pigeon% ./ruby -ve ‘a, b = /(.)/.match(“ab”); p a,b’
ruby 1.6.0 (2000-09-19) [i686-linux]
#MatchData:0x401adc48
nil
pigeon%

I meant from 1.6.7 to 1.6.8, which was what Austin had mentioned:

knossos:~$ ruby -ve ‘a, b = /(.)/.match(“ab”); p a,b’
ruby 1.6.7 (2002-03-01) [i686-linux]
#MatchData:0x40181a54
nil

dblack@laptop:~$ ruby -ve ‘a, b = /(.)/.match(“ab”); p a,b’
ruby 1.6.8 (2002-12-24) [i686-linux-gnu]
#MatchData:0x401bf98c
nil

David

···

On Mon, 31 Mar 2003, ts wrote:


David Alan Black
home: dblack@superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

I must correct myself – I was originally using the 1.7 release by
PragProg. So my unit test would have failed under 1.6.7; I just
never tested it to be sure. What I’m doing now:

l = /((?:\S+\s+){11}(.+)/.match(line)

And then using l[1] and l[2] is safer and more portable betweeen
versions, IMO.

I think that expecting #match to return an array in any case is a
bad thing. But that’s just IMO.

-austin
– Austin Ziegler, austin@halostatue.ca on 2003.03.31 at 23:12:16

···

On Tue, 1 Apr 2003 12:24:07 +0900, dblack@superlink.net wrote:

On Tue, 1 Apr 2003, Yukihiro Matsumoto wrote:

In 1.6.7 and 1.7, I had the following line work:
l, m1, m2 = /((?:\S+\s+){11})(.+)/.match(line)

This meant that #match return worked like an array.
Put “*” before the expression, e.g.

l, m1, m2 = */((?:\S+\s+){11})(.+)/.match(line)

I’m getting confused… It looks like 1.8 goes back to the 1.4
behavior – am I right about that?

Hi,

I’m getting confused… It looks like 1.8 goes back to the 1.4
behavior – am I right about that?

candle:~$ ruby -ve ‘a, b = /(.)/.match(“ab”); p a,b’
ruby 1.8.0 (2003-03-03) [i686-linux]
“a”
“a”

It was a bug to be fixed.

and for the other behavior, the * doesn’t seem to change it (in this
1.6.8 example):

It should work on the latest.

% ruby -ve ‘a, b = /(.)/.match(“ab”); p a,b’
ruby 1.8.0 (2003-03-28) [i686-linux]
#MatchData:0x401a5398
nil
% ruby -ve ‘a, b = */(.)/.match(“ab”); p a,b’
ruby 1.8.0 (2003-03-28) [i686-linux]
“a”
“a”

Sorry, I forget about 1.6.8 already.

						matz.
···

In message “Re: Change to /…/.match(“foo”) behaviour in 1.6.8?” on 03/04/01, dblack@superlink.net dblack@superlink.net writes:

I meant from 1.6.7 to 1.6.8, which was what Austin had mentioned:

I've understood but, like you, I was unable to reproduce this behavior
with 1.6.7. For me, this is a difference 1.4/1.6

Guy Decoux