From: "Januski, Ken" Date: 2008-04-03T11:23:47+09:00 Subject: Re: confused by 'test'.gsub(/.*/,'x') ------_=_NextPart_001_01C89531.B90C33CC Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Right you are. For all the years I've used Perl, and for all that I = thought I knew about regexes, I never would have thought I would get = that result. I would have expected one greedy match for the entire text. Instead I = guess it's first getting the zero match and then the full match. -----Original Message----- From: Jens Wille [mailto:jens.wille@uni-koeln.de] Sent: Wed 4/2/2008 7:03 PM To: ruby-talk ML Subject: Re: confused by 'test'.gsub(/.*/,'x') =20 Januski, Ken [2008-04-03 00:08]: > Of course my background is Perl and I believe that's how it would > work there. no, works the same way there: sh> perl -e '$s =3D "test"; $s =3D~ s/.*/x/g; print "$s\n"' xx (only a lot more complicated ;-) btw: python, php and javascript, too. oh, and here's what oniguruma does: irb> Oniguruma::ORegexp.new('.*').gsub('test', 'x') =3D>"xx" cheers jens ------_=_NextPart_001_01C89531.B90C33CC--