From: Kristof Bastiaensen Date: 2004-06-30T03:08:00+09:00 Subject: Re: another strange regexp case On Tue, 29 Jun 2004 11:05:43 -0600, Ara.T.Howard wrote: >> irb(main):004:0> /(theone)?/.match(" theone").to_a >> => ["", nil] > > ? means 'zero or one' > > we start a the beginning of ' theone' and instantly find a match: zero of > them. > > if you create a regexp without anchors and with portions that can match zero > things and have not done so out of absolute need - your code has a bug. Thanks for the answer. I expected the pattern to expand greedily, but I forgot it will return the first match, which is the empty match. You are right, /(theone)?/ is a silly thing to write, finally I just needed another regexp for my problem. Thanks, Kristof