Ted
(Ted)
1
.. and it returns 'nil' for no match?
···
> perl -e 'print "foobar" =~ /foo bar/x' >> 1
> ruby -e 'print "foobar" =~ /foo bar/x' >> 0
Perl is returning whether there was a match (undef if no match).
Ruby is returning the offset of the match (strings start at 0).
perl -e ‘print “foobar” =~ /foo bar/x’ >> 1
ruby -e ‘print “foobar” =~ /foo bar/x’ >> 0
Perl is returning whether there was a match (undef if no match).
Ruby is returning the offset of the match (strings start at 0).
… and it returns ‘nil’ for no match?
Correct. The ruby equivalent of undef =)
ruby -e ‘print “foobar” =~ /fred/’
perl -e ‘print “foobar” =~ /fred/’
cheers,
···
–
Iain.